From e9ab9917162330df3239199c2260255462f1cdfe Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 6 Aug 2008 22:34:37 +0100 Subject: Really fix the metadata bug... --- src/xine-engine/info_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xine-engine/info_helper.c b/src/xine-engine/info_helper.c index 242805915..34d1bbdba 100644 --- a/src/xine-engine/info_helper.c +++ b/src/xine-engine/info_helper.c @@ -131,7 +131,7 @@ uint32_t _x_stream_info_get_public(xine_stream_t *stream, int info) { * at the end of the string */ static void meta_info_chomp(char *str) { - size_t i, len; + ssize_t i, len; len = strlen(str); if (!len) -- cgit v1.2.3 From 0b504bf028bf83ffc1783ae321f089e7b8406c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 8 Jul 2008 15:36:07 +0200 Subject: Avoid using strlen() in loops, calculate it beforehand. --HG-- extra : transplant_source : %80%12%03%93%EFL%FC%AF%A6%22Z%D0%95C%D5%29%AF%FB%95%B2 --- src/input/input_dvb.c | 11 ++++++----- src/input/libreal/sdpplin.c | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index bc279b78b..19b479a06 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -1664,21 +1664,22 @@ static void load_epg_data(dvb_input_plugin_t *this) } /* Prints text to an area, tries to cut the lines in between words. */ -static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, char* text, +static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, const char* text, int x, int y, int row_space, int max_x, int max_y, int* height, int color_base) { /* The position of the text to be printed. */ - char* cursor = text; + const char* cursor = text; + const char *const text_end = text + strlen(text); /* The line to be printed next. */ char text_line[512]; int text_width, text_height; size_t old_line_length, line_cursor; - char* bound, *old_bound; + const char* bound, *old_bound; *height = 0; - while (cursor < text + strlen(text)) { + while (cursor < text_end) { bound = cursor; line_cursor = 0; text_line[0] = '\0'; @@ -1735,7 +1736,7 @@ static void render_text_area(osd_renderer_t* renderer, osd_object_t* osd, char* } /* OK, it did fit, let's try to fit some more. */ - } while (bound < text + strlen(text)); + } while (bound < text_end); if (y + text_height + row_space > max_y) { break; diff --git a/src/input/libreal/sdpplin.c b/src/input/libreal/sdpplin.c index f3672559c..c1fab49c1 100644 --- a/src/input/libreal/sdpplin.c +++ b/src/input/libreal/sdpplin.c @@ -60,7 +60,8 @@ static char *b64_decode(const char *in, char *out, int *size) k=0; /*CONSTANTCONDITION*/ - for (j=0; j Date: Tue, 8 Jul 2008 15:36:28 +0200 Subject: Rename flag so that NOFILE won't be redefining a system constant. --HG-- extra : transplant_source : %5B%DAd%7EO%08%09I%B0%95%9B%EDg-%60%CB%252%84%F2 --- src/demuxers/iff.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/iff.h b/src/demuxers/iff.h index 94830f69c..8ac24a697 100644 --- a/src/demuxers/iff.h +++ b/src/demuxers/iff.h @@ -27,8 +27,8 @@ #define IFFP_IFF_H #define IFF_OKAY 0L -#define CLIENT_ERROR 1L -#define NOFILE 5L +#define IFF_CLIENT_ERROR 1L +#define IFF_NOFILE 5L #define FOURCC_CHUNK BE_FOURCC #define IFF_16SV_CHUNK FOURCC_CHUNK('1', '6', 'S', 'V') -- cgit v1.2.3 From d552d3b8f3149d66d359928d9626f2c34fddc02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 8 Jul 2008 15:50:55 +0200 Subject: Avoid definition of MAX that clashes with MAX() macro. --HG-- extra : transplant_source : %EFv%DC%FD%DA%23%BB%B8i3%07%A9e%C0%06o%9C%8A%B6_ --- src/post/goom/convolve_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/post/goom/convolve_fx.c b/src/post/goom/convolve_fx.c index e86bb3723..c394f3bf8 100644 --- a/src/post/goom/convolve_fx.c +++ b/src/post/goom/convolve_fx.c @@ -20,7 +20,7 @@ typedef char Motif[CONV_MOTIF_W][CONV_MOTIF_W]; #define NB_THETA 512 -#define MAX 2.0f +//#define MAX 2.0f typedef struct _CONV_DATA{ PluginParam light; -- cgit v1.2.3 From a9cbcc9a321b8baaf71b9a19d2b8ffde4390c6f9 Mon Sep 17 00:00:00 2001 From: Simon Farnsworth Date: Wed, 23 Jul 2008 11:13:20 +0100 Subject: Xv deinterlacing was looking at the input image size, not the output image size. This works fine on some chipsets, but on others, it causes image corruption. --- src/video_out/video_out_xv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_out/video_out_xv.c b/src/video_out/video_out_xv.c index 8f5da8ea0..6a11ebc34 100644 --- a/src/video_out/video_out_xv.c +++ b/src/video_out/video_out_xv.c @@ -524,7 +524,7 @@ static void xv_deinterlace_frame (xv_driver_t *this) { for( i = 0; i < VO_NUM_RECENT_FRAMES; i++ ) if( this->recent_frames[i] && this->recent_frames[i]->width == frame->width && this->recent_frames[i]->height == frame->height ) - recent_bitmaps[i] = this->recent_frames[i]->image->data + frame->width*frame->height; + recent_bitmaps[i] = this->recent_frames[i]->image->data + this->deinterlace_frame.image->width*frame->height; else recent_bitmaps[i] = NULL; -- cgit v1.2.3 From a5d25b426a852306d74c4e4ecf39b1e3de289945 Mon Sep 17 00:00:00 2001 From: Simon Farnsworth Date: Mon, 28 Jul 2008 17:14:41 +0100 Subject: Preallocate after we know how large the frames will be (fixes a buffer overrun) --- src/input/input_v4l.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index 00c579c44..9e6b783e3 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -892,10 +892,6 @@ static int open_video_capture_device(v4l_input_plugin_t *this) _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1); _x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_VIDEO, 1); - /* Pre-allocate some frames for audio and video so it doesn't have to be - * done during capture */ - allocate_frames(this, 1); - /* Unmute audio off video capture device */ unmute_audio(this); @@ -1004,7 +1000,11 @@ static int open_video_capture_device(v4l_input_plugin_t *this) xine_set_param(this->stream, XINE_PARAM_VO_ZOOM_X, 103); xine_set_param(this->stream, XINE_PARAM_VO_ZOOM_Y, 103); - + + /* Pre-allocate some frames for audio and video so it doesn't have to be + * done during capture */ + allocate_frames(this, 1); + /* If we made it here, everything went ok */ this->audio_only = 0; if (tuner_found) -- cgit v1.2.3 From 785fb4931f9d50716810cb4cc2355133fb37b462 Mon Sep 17 00:00:00 2001 From: Simon Farnsworth Date: Mon, 28 Jul 2008 17:17:39 +0100 Subject: Only set the tuner if we're going to use it (fixes baseband video inputs) --- src/input/input_v4l.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index 9e6b783e3..b97f11ace 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -549,6 +549,12 @@ static int set_frequency(v4l_input_plugin_t *this, unsigned long frequency) fd = this->radio_fd; if (frequency != 0) { + /* FIXME: Don't assume tuner 0 ? */ + this->tuner = 0; + ret = ioctl(fd, VIDIOCSTUNER, &this->tuner); + lprintf("(%d) Response on set tuner to %d\n", ret, this->tuner); + this->video_tuner.tuner = this->tuner; + if (this->video_tuner.flags & VIDEO_TUNER_LOW) { this->calc_frequency = frequency * 16; } else { @@ -683,16 +689,6 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source) ret = ioctl(fd, VIDIOCSCHAN, &this->input); lprintf("(%d) Set channel to %d\n", ret, this->input); - - /* FIXME: Don't assume tuner 0 ? */ - - this->tuner = 0; - - ret = ioctl(fd, VIDIOCSTUNER, &this->tuner); - - lprintf("(%d) Response on set tuner to %d\n", ret, this->tuner); - - this->video_tuner.tuner = this->tuner; } else { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: Not setting video source. No source given\n"); -- cgit v1.2.3 From 6f79d815918aa83d706b6dc6722c2006f27e8084 Mon Sep 17 00:00:00 2001 From: Matthias Hopf Date: Fri, 1 Aug 2008 20:06:33 +0200 Subject: video_out_opengl: Activate only if visual is direct rendering capable --- src/video_out/video_out_opengl.c | 58 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c index af1093e91..88460928b 100644 --- a/src/video_out/video_out_opengl.c +++ b/src/video_out/video_out_opengl.c @@ -1953,6 +1953,51 @@ static vo_driver_t *opengl_open_plugin (video_driver_class_t *class_gen, const v * class functions */ +static int opengl_verify_direct (x11_visual_t *vis) { + int attribs[] = { + GLX_RGBA, + GLX_RED_SIZE, 1, + GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, + None + }; + Window root, win; + XVisualInfo *visinfo; + GLXContext ctx; + XSetWindowAttributes xattr; + int ret = 0; + + if (!vis || !vis->display || + ! (root = RootWindow (vis->display, vis->screen))) { + fprintf (stderr, "[videoout_opengl]: Don't have a root window to verify\n"); + } + if (! (visinfo = glXChooseVisual (vis->display, vis->screen, attribs))) + return 0; + if (! (ctx = glXCreateContext (vis->display, visinfo, NULL, 1))) + return 0; + memset (&xattr, 0, sizeof (xattr)); + xattr.colormap = XCreateColormap(vis->display, root, visinfo->visual, AllocNone); + xattr.event_mask = StructureNotifyMask | ExposureMask; + if ( (win = XCreateWindow (vis->display, root, 0, 0, 1, 1, 0, visinfo->depth, + InputOutput, visinfo->visual, + CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, + &xattr))) { + if (glXMakeCurrent (vis->display, win, ctx)) { + const char *renderer = (const char *) glGetString(GL_RENDERER); + if (glXIsDirect (vis->display, ctx) && + ! strstr (renderer, "Software") && + ! strstr (renderer, "Indirect")) + ret = 1; + glXMakeCurrent (vis->display, None, NULL); + } + XDestroyWindow (vis->display, win); + } + glXDestroyContext (vis->display, ctx); + XFreeColormap (vis->display, xattr.colormap); + + return ret; +} + static char* opengl_get_identifier (video_driver_class_t *this_gen) { return "opengl"; } @@ -1968,7 +2013,18 @@ static void opengl_dispose_class (video_driver_class_t *this_gen) { } static void *opengl_init_class (xine_t *xine, void *visual_gen) { - opengl_class_t *this = (opengl_class_t *) calloc(1, sizeof(opengl_class_t)); + + opengl_class_t *this; + + xprintf (xine, XINE_VERBOSITY_LOG, + "video_out_opengl: Testing for hardware accelerated direct rendering visual\n"); + if (! opengl_verify_direct ((x11_visual_t *)visual_gen)) { + xprintf (xine, XINE_VERBOSITY_LOG, + "video_out_opengl: Didn't find any\n"); + return NULL; + } + + this = (opengl_class_t *) calloc (1, sizeof(opengl_class_t)); this->driver_class.open_plugin = opengl_open_plugin; this->driver_class.get_identifier = opengl_get_identifier; -- cgit v1.2.3 From 5be02c29c6239586e40a5d3296001302b5d6ab1a Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 6 Aug 2008 22:09:07 +0100 Subject: Fix crashes with fuzzed Windows Media files. --HG-- extra : transplant_source : %92%2C%CB%01S%25N%22%E1%00%FB%19%B0%CE5%1BU%F9%F6%0A --- src/demuxers/demux_asf.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index 3af265ce4..3a0720043 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -70,6 +70,7 @@ #define ASF_MODE_HTTP_REF 2 #define ASF_MODE_ASF_REF 3 #define ASF_MODE_ENCRYPTED_CONTENT 4 +#define ASF_MODE_NO_CONTENT 5 typedef struct { int seq; @@ -443,6 +444,14 @@ static int asf_read_header (demux_asf_t *this) { asf_stream_t *asf_stream = this->asf_header->streams[i]; asf_demux_stream_t *demux_stream = &this->streams[i]; + if (!asf_stream && this->mode != ASF_MODE_NO_CONTENT) { + xine_log(this->stream->xine, XINE_LOG_MSG, + _("demux_asf: warning: The stream id=%d appears to be missing.\n"), asf_stream->stream_number); + _x_message(this->stream, XINE_MSG_READ_ERROR, + _("Media stream missing?"), NULL); + this->mode = ASF_MODE_NO_CONTENT; + } + if (asf_stream->encrypted_flag) { if (this->mode != ASF_MODE_ENCRYPTED_CONTENT) { xine_log(this->stream->xine, XINE_LOG_MSG, @@ -1679,6 +1688,7 @@ static int demux_asf_send_chunk (demux_plugin_t *this_gen) { return demux_asf_parse_asf_references(this); case ASF_MODE_ENCRYPTED_CONTENT: + case ASF_MODE_NO_CONTENT: this->status = DEMUX_FINISHED; return this->status; -- cgit v1.2.3 From afa345a236a04cb2526fa9350b1767fdd9972fcf Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Thu, 7 Aug 2008 14:03:52 +0100 Subject: Fix crashes with fuzzed Ogg files. (CVE-2008-3231) --HG-- extra : transplant_source : %9F%E8R%D8%94R%9CJ%7F%5E%A7%DB%29%0DK%CD%CA%AD%7F%08 --- src/demuxers/demux_ogg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index 2cbba982f..9e9de45aa 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -1357,7 +1357,7 @@ static void send_header (demux_ogg_t *this) { this->ignore_keyframes = 0; while (!done) { - if (!read_ogg_packet(this)) { + if (!read_ogg_packet(this) || !this->og.header || !this->og.body) { return; } /* now we've got at least one new page */ @@ -1483,6 +1483,12 @@ static int demux_ogg_send_chunk (demux_plugin_t *this_gen) { return this->status; } + if (!this->og.header || !this->og.body) { + this->status = DEMUX_FINISHED; + lprintf ("EOF\n"); + return this->status; + } + /* now we've got one new page */ cur_serno = ogg_page_serialno (&this->og); -- cgit v1.2.3 From 187ae21aaeee0c4c1a6aee2b9808b884af827437 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Thu, 7 Aug 2008 18:51:26 +0100 Subject: Fix a segfault introduced in the Windows Media crash fix. --- src/demuxers/demux_asf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_asf.c b/src/demuxers/demux_asf.c index 3a0720043..9d4191633 100644 --- a/src/demuxers/demux_asf.c +++ b/src/demuxers/demux_asf.c @@ -444,13 +444,16 @@ static int asf_read_header (demux_asf_t *this) { asf_stream_t *asf_stream = this->asf_header->streams[i]; asf_demux_stream_t *demux_stream = &this->streams[i]; - if (!asf_stream && this->mode != ASF_MODE_NO_CONTENT) { + if (!asf_stream) { + if (this->mode != ASF_MODE_NO_CONTENT) { xine_log(this->stream->xine, XINE_LOG_MSG, - _("demux_asf: warning: The stream id=%d appears to be missing.\n"), asf_stream->stream_number); + _("demux_asf: warning: A stream appears to be missing.\n")); _x_message(this->stream, XINE_MSG_READ_ERROR, _("Media stream missing?"), NULL); this->mode = ASF_MODE_NO_CONTENT; } + return 0; + } if (asf_stream->encrypted_flag) { if (this->mode != ASF_MODE_ENCRYPTED_CONTENT) { -- cgit v1.2.3 From f5ccbf8b80ae8b82f9857cae2afbadf849d1fd64 Mon Sep 17 00:00:00 2001 From: Matthias Hopf Date: Fri, 8 Aug 2008 17:20:24 +0200 Subject: video_out_opengl: Actually bail out if no display found. --- src/video_out/video_out_opengl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/video_out/video_out_opengl.c b/src/video_out/video_out_opengl.c index 88460928b..a8f11db2f 100644 --- a/src/video_out/video_out_opengl.c +++ b/src/video_out/video_out_opengl.c @@ -1970,6 +1970,7 @@ static int opengl_verify_direct (x11_visual_t *vis) { if (!vis || !vis->display || ! (root = RootWindow (vis->display, vis->screen))) { fprintf (stderr, "[videoout_opengl]: Don't have a root window to verify\n"); + return 0; } if (! (visinfo = glXChooseVisual (vis->display, vis->screen, attribs))) return 0; -- cgit v1.2.3 From 344c697e75c3fdd1067dc90fc2edc7a19c49466b Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 8 Aug 2008 11:10:30 +0100 Subject: Fix crash with corrupted AVI files (chunk size). --HG-- extra : transplant_source : Z%F0%90e%A3%94%D3%7F%D9ROC8%3C%FD%F5FO%BFU --- src/demuxers/demux_avi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 16b897711..0ab3448bb 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -317,6 +317,8 @@ typedef struct { getIndex==0, but an operation has been performed that needs an index */ +#define AVI_ERR_BAD_SIZE 14 /* A chunk has an invalid size */ + #define AVI_HEADER_UNKNOWN -1 #define AVI_HEADER_AUDIO 0 #define AVI_HEADER_VIDEO 1 @@ -780,7 +782,7 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { lprintf("chunk: %c%c%c%c, size: %" PRId64 "\n", data[0], data[1], data[2], data[3], (int64_t)n); - if((strncasecmp(data,"LIST",4) == 0) && (n >= 4)) { + if (n >= 4 && strncasecmp(data,"LIST",4) == 0) { if( this->input->read(this->input, data,4) != 4 ) ERR_EXIT(AVI_ERR_READ); n -= 4; @@ -835,6 +837,8 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { /* Interpret the header list */ for (i = 0; i < hdrl_len;) { + const int old_i = i; + /* List tags are completly ignored */ lprintf("tag: %c%c%c%c\n", hdrl_data[i], hdrl_data[i+1], hdrl_data[i+2], hdrl_data[i+3]); @@ -1081,6 +1085,8 @@ static avi_t *XINE_MALLOC AVI_init(demux_avi_t *this) { lasttag = 0; } i += n; + if (i <= old_i) + ERR_EXIT(AVI_ERR_BAD_SIZE); } if( hdrl_data ) -- cgit v1.2.3 From 3a6da3fcaef64afe71e1e1a0d41baca0872e98f8 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 8 Aug 2008 11:18:08 +0100 Subject: Fix crash with corrupted WMV files when checking for aspect ratio information. --HG-- extra : transplant_source : kW%D0IN%9D%8D%D4l%F6%3C%D0%CF%9CT%A9%B2%7D%9E%E9 --- src/demuxers/asfheader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c index 1b71a0b19..e9a36fc29 100644 --- a/src/demuxers/asfheader.c +++ b/src/demuxers/asfheader.c @@ -545,12 +545,12 @@ static int asf_header_parse_metadata(asf_header_t *header_pub, uint8_t *buffer, if (data_len >= 4) { char *name = asf_reader_get_string (&reader, name_len, iconv_cd); - if (!strcmp (name, "AspectRatioX")) + if (name && !strcmp (name, "AspectRatioX")) { asf_reader_get_32 (&reader, &header->pub.aspect_ratios[stream_id].x); data_len -= 4; } - else if (!strcmp (name, "AspectRatioY")) + else if (name && !strcmp (name, "AspectRatioY")) { asf_reader_get_32 (&reader, &header->pub.aspect_ratios[stream_id].y); data_len -= 4; -- cgit v1.2.3 From e8cc3903fc5be11c0e326fc23650599dbb1d07a0 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 13 Aug 2008 14:28:30 +0100 Subject: Update to libfaad 2.6.1, fixing a crash with a corrupted AAC file. Source is the version in the 1.2 branch. --- src/libfaad/Makefile.am | 16 +- src/libfaad/analysis.h | 9 +- src/libfaad/bits.c | 156 +- src/libfaad/bits.h | 162 +- src/libfaad/cfft.c | 29 +- src/libfaad/cfft.h | 9 +- src/libfaad/cfft_tab.h | 17 +- src/libfaad/codebook/hcb.h | 9 +- src/libfaad/codebook/hcb_1.h | 9 +- src/libfaad/codebook/hcb_10.h | 9 +- src/libfaad/codebook/hcb_11.h | 9 +- src/libfaad/codebook/hcb_2.h | 9 +- src/libfaad/codebook/hcb_3.h | 9 +- src/libfaad/codebook/hcb_4.h | 9 +- src/libfaad/codebook/hcb_5.h | 9 +- src/libfaad/codebook/hcb_6.h | 9 +- src/libfaad/codebook/hcb_7.h | 9 +- src/libfaad/codebook/hcb_8.h | 9 +- src/libfaad/codebook/hcb_9.h | 9 +- src/libfaad/codebook/hcb_sf.h | 9 +- src/libfaad/common.c | 23 +- src/libfaad/common.h | 106 +- src/libfaad/decoder.c | 125 +- src/libfaad/decoder.h | 9 +- src/libfaad/drc.c | 9 +- src/libfaad/drc.h | 9 +- src/libfaad/drm_dec.c | 117 +- src/libfaad/drm_dec.h | 11 +- src/libfaad/error.c | 16 +- src/libfaad/error.h | 11 +- src/libfaad/filtbank.c | 9 +- src/libfaad/filtbank.h | 9 +- src/libfaad/fixed.h | 28 +- src/libfaad/hcr.c | 33 +- src/libfaad/huffman.c | 9 +- src/libfaad/huffman.h | 9 +- src/libfaad/ic_predict.c | 20 +- src/libfaad/ic_predict.h | 9 +- src/libfaad/iq_table.h | 9 +- src/libfaad/is.c | 11 +- src/libfaad/is.h | 9 +- src/libfaad/kbd_win.h | 9 +- src/libfaad/lt_predict.c | 14 +- src/libfaad/lt_predict.h | 9 +- src/libfaad/mdct.c | 11 +- src/libfaad/mdct.h | 9 +- src/libfaad/mdct_tab.h | 9 +- src/libfaad/mp4.c | 25 +- src/libfaad/mp4.h | 9 +- src/libfaad/ms.c | 11 +- src/libfaad/ms.h | 9 +- src/libfaad/output.c | 71 +- src/libfaad/output.h | 9 +- src/libfaad/pns.c | 34 +- src/libfaad/pns.h | 12 +- src/libfaad/ps_dec.c | 159 +- src/libfaad/ps_dec.h | 9 +- src/libfaad/ps_syntax.c | 22 +- src/libfaad/ps_tables.h | 19 +- src/libfaad/pulse.c | 12 +- src/libfaad/pulse.h | 9 +- src/libfaad/rvlc.c | 9 +- src/libfaad/rvlc.h | 9 +- src/libfaad/sbr_dct.c | 3552 +++++++++++++++++++++-------------------- src/libfaad/sbr_dct.h | 9 +- src/libfaad/sbr_dec.c | 106 +- src/libfaad/sbr_dec.h | 19 +- src/libfaad/sbr_e_nf.c | 9 +- src/libfaad/sbr_e_nf.h | 9 +- src/libfaad/sbr_fbt.c | 9 +- src/libfaad/sbr_fbt.h | 9 +- src/libfaad/sbr_hfadj.c | 54 +- src/libfaad/sbr_hfadj.h | 15 +- src/libfaad/sbr_hfgen.c | 10 +- src/libfaad/sbr_hfgen.h | 9 +- src/libfaad/sbr_huff.c | 9 +- src/libfaad/sbr_huff.h | 9 +- src/libfaad/sbr_noise.h | 9 +- src/libfaad/sbr_qmf.c | 27 +- src/libfaad/sbr_qmf.h | 9 +- src/libfaad/sbr_qmf_c.h | 17 +- src/libfaad/sbr_syntax.c | 71 +- src/libfaad/sbr_syntax.h | 12 +- src/libfaad/sbr_tf_grid.c | 9 +- src/libfaad/sbr_tf_grid.h | 9 +- src/libfaad/sine_win.h | 9 +- src/libfaad/specrec.c | 174 +- src/libfaad/specrec.h | 9 +- src/libfaad/ssr.c | 9 +- src/libfaad/ssr.h | 9 +- src/libfaad/ssr_fb.c | 9 +- src/libfaad/ssr_fb.h | 15 +- src/libfaad/ssr_ipqf.c | 9 +- src/libfaad/ssr_ipqf.h | 15 +- src/libfaad/ssr_win.h | 15 +- src/libfaad/structs.h | 28 +- src/libfaad/syntax.c | 308 ++-- src/libfaad/syntax.h | 16 +- src/libfaad/tns.c | 19 +- src/libfaad/tns.h | 9 +- 100 files changed, 3569 insertions(+), 2670 deletions(-) (limited to 'src') diff --git a/src/libfaad/Makefile.am b/src/libfaad/Makefile.am index 729418f1c..92c1fe585 100644 --- a/src/libfaad/Makefile.am +++ b/src/libfaad/Makefile.am @@ -103,4 +103,18 @@ noinst_HEADERS = \ ssr_win.h \ structs.h \ syntax.h \ - tns.h + tns.h \ + neaacdec.h \ + codebook/hcb.h \ + codebook/hcb_1.h \ + codebook/hcb_2.h \ + codebook/hcb_3.h \ + codebook/hcb_4.h \ + codebook/hcb_5.h \ + codebook/hcb_6.h \ + codebook/hcb_7.h \ + codebook/hcb_8.h \ + codebook/hcb_9.h \ + codebook/hcb_10.h \ + codebook/hcb_11.h \ + codebook/hcb_sf.h diff --git a/src/libfaad/analysis.h b/src/libfaad/analysis.h index 810a95f3b..50e43fa04 100644 --- a/src/libfaad/analysis.h +++ b/src/libfaad/analysis.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: analysis.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: analysis.h,v 1.18 2007/11/01 12:33:29 menno Exp $ **/ #ifndef __ANALYSIS_H__ diff --git a/src/libfaad/bits.c b/src/libfaad/bits.c index ae273c7d8..dc14d7a03 100644 --- a/src/libfaad/bits.c +++ b/src/libfaad/bits.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,17 +19,19 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: bits.c,v 1.9 2005/10/29 23:57:06 tmmm Exp $ +** $Id: bits.c,v 1.44 2007/11/01 12:33:29 menno Exp $ **/ #include "common.h" #include "structs.h" #include -#include #include "bits.h" /* initialize buffer, call once before first getbits or showbits */ @@ -40,25 +42,38 @@ void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) if (ld == NULL) return; - memset(ld, 0, sizeof(bitfile)); + // useless + //memset(ld, 0, sizeof(bitfile)); if (buffer_size == 0 || _buffer == NULL) { ld->error = 1; - ld->no_more_reading = 1; return; } - ld->buffer = faad_malloc((buffer_size+12)*sizeof(uint8_t)); - memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t)); - memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t)); + ld->buffer = _buffer; ld->buffer_size = buffer_size; + ld->bytes_left = buffer_size; - tmp = getdword((uint32_t*)ld->buffer); + if (ld->bytes_left >= 4) + { + tmp = getdword((uint32_t*)ld->buffer); + ld->bytes_left -= 4; + } else { + tmp = getdword_n((uint32_t*)ld->buffer, ld->bytes_left); + ld->bytes_left = 0; + } ld->bufa = tmp; - tmp = getdword((uint32_t*)ld->buffer + 1); + if (ld->bytes_left >= 4) + { + tmp = getdword((uint32_t*)ld->buffer + 1); + ld->bytes_left -= 4; + } else { + tmp = getdword_n((uint32_t*)ld->buffer + 1, ld->bytes_left); + ld->bytes_left = 0; + } ld->bufb = tmp; ld->start = (uint32_t*)ld->buffer; @@ -66,21 +81,12 @@ void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) ld->bits_left = 32; - ld->bytes_used = 0; - ld->no_more_reading = 0; ld->error = 0; } void faad_endbits(bitfile *ld) { - if (ld) - { - if (ld->buffer) - { - faad_free(ld->buffer); - ld->buffer = NULL; - } - } + // void } uint32_t faad_get_processed_bits(bitfile *ld) @@ -90,12 +96,12 @@ uint32_t faad_get_processed_bits(bitfile *ld) uint8_t faad_byte_align(bitfile *ld) { - uint8_t remainder = (uint8_t)((32 - ld->bits_left) % 8); + int remainder = (32 - ld->bits_left) & 0x7; if (remainder) { faad_flushbits(ld, 8 - remainder); - return (8 - remainder); + return (uint8_t)(8 - remainder); } return 0; } @@ -105,20 +111,22 @@ void faad_flushbits_ex(bitfile *ld, uint32_t bits) uint32_t tmp; ld->bufa = ld->bufb; - if (ld->no_more_reading == 0) + if (ld->bytes_left >= 4) { tmp = getdword(ld->tail); - ld->tail++; + ld->bytes_left -= 4; } else { - tmp = 0; + tmp = getdword_n(ld->tail, ld->bytes_left); + ld->bytes_left = 0; } ld->bufb = tmp; + ld->tail++; ld->bits_left += (32 - bits); - ld->bytes_used += 4; - if (ld->bytes_used == ld->buffer_size) - ld->no_more_reading = 1; - if (ld->bytes_used > ld->buffer_size) - ld->error = 1; + //ld->bytes_left -= 4; +// if (ld->bytes_left == 0) +// ld->no_more_reading = 1; +// if (ld->bytes_left < 0) +// ld->error = 1; } /* rewind to beginning */ @@ -126,30 +134,79 @@ void faad_rewindbits(bitfile *ld) { uint32_t tmp; - tmp = ld->start[0]; -#ifndef ARCH_IS_BIG_ENDIAN - BSWAP(tmp); -#endif + ld->bytes_left = ld->buffer_size; + + if (ld->bytes_left >= 4) + { + tmp = getdword((uint32_t*)&ld->start[0]); + ld->bytes_left -= 4; + } else { + tmp = getdword_n((uint32_t*)&ld->start[0], ld->bytes_left); + ld->bytes_left = 0; + } ld->bufa = tmp; - tmp = ld->start[1]; -#ifndef ARCH_IS_BIG_ENDIAN - BSWAP(tmp); -#endif + if (ld->bytes_left >= 4) + { + tmp = getdword((uint32_t*)&ld->start[1]); + ld->bytes_left -= 4; + } else { + tmp = getdword_n((uint32_t*)&ld->start[1], ld->bytes_left); + ld->bytes_left = 0; + } ld->bufb = tmp; + ld->bits_left = 32; ld->tail = &ld->start[2]; - ld->bytes_used = 0; - ld->no_more_reading = 0; +} + +/* reset to a certain point */ +void faad_resetbits(bitfile *ld, int bits) +{ + uint32_t tmp; + int words = bits >> 5; + int remainder = bits & 0x1F; + + ld->bytes_left = ld->buffer_size - words*4; + + if (ld->bytes_left >= 4) + { + tmp = getdword(&ld->start[words]); + ld->bytes_left -= 4; + } else { + tmp = getdword_n(&ld->start[words], ld->bytes_left); + ld->bytes_left = 0; + } + ld->bufa = tmp; + + if (ld->bytes_left >= 4) + { + tmp = getdword(&ld->start[words+1]); + ld->bytes_left -= 4; + } else { + tmp = getdword_n(&ld->start[words+1], ld->bytes_left); + ld->bytes_left = 0; + } + ld->bufb = tmp; + + ld->bits_left = 32 - remainder; + ld->tail = &ld->start[words+2]; + + /* recheck for reading too many bytes */ + ld->error = 0; +// if (ld->bytes_left == 0) +// ld->no_more_reading = 1; +// if (ld->bytes_left < 0) +// ld->error = 1; } uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits DEBUGDEC) { - uint16_t i; - uint8_t temp; - uint16_t bytes = (uint16_t)bits / 8; - uint8_t remainder = (uint8_t)bits % 8; + int i; + unsigned int temp; + int bytes = bits >> 3; + int remainder = bits & 0x7; uint8_t *buffer = (uint8_t*)faad_malloc((bytes+1)*sizeof(uint8_t)); @@ -160,9 +217,9 @@ uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits if (remainder) { - temp = (uint8_t)faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder); + temp = faad_getbits(ld, remainder DEBUGVAR(print,var,dbg)) << (8-remainder); - buffer[bytes] = temp; + buffer[bytes] = (uint8_t)temp; } return buffer; @@ -207,7 +264,8 @@ void faad_initbits_rev(bitfile *ld, void *buffer, if (ld->bits_left == 0) ld->bits_left = 32; - ld->bytes_used = 0; - ld->no_more_reading = 0; + ld->bytes_left = ld->buffer_size; ld->error = 0; } + +/* EOF */ diff --git a/src/libfaad/bits.h b/src/libfaad/bits.h index 05460f0cc..e303e8e72 100644 --- a/src/libfaad/bits.h +++ b/src/libfaad/bits.h @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: bits.h,v 1.11 2005/10/30 01:21:53 tmmm Exp $ +** $Id: bits.h,v 1.45 2007/11/01 12:33:29 menno Exp $ **/ #ifndef __BITS_H__ @@ -37,8 +40,10 @@ extern "C" { #include #endif -#define BYTE_NUMBIT 8 -#define bit2byte(a) ((a+7)/BYTE_NUMBIT) +#define BYTE_NUMBIT 8 +#define BYTE_NUMBIT_LD 3 +//#define bit2byte(a) ((a+7)/BYTE_NUMBIT) +#define bit2byte(a) ((a+7)>>BYTE_NUMBIT_LD) typedef struct _bitfile { @@ -47,25 +52,16 @@ typedef struct _bitfile uint32_t bufb; uint32_t bits_left; uint32_t buffer_size; /* size of the buffer in bytes */ - uint32_t bytes_used; - uint8_t no_more_reading; + uint32_t bytes_left; uint8_t error; uint32_t *tail; uint32_t *start; - void *buffer; + const void *buffer; } bitfile; -#if defined(_MSC_VER) -#define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax -#elif defined(LINUX) || defined(DJGPP) || defined (__MINGW32__) || defined (__CYGWIN__) -#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) -#else -#define BSWAP(a) \ - ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) -#endif - -static uint32_t bitmask[] = { +#if 0 +static uint32_t const bitmask[] = { 0x0, 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F, 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF, 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, @@ -74,6 +70,7 @@ static uint32_t bitmask[] = { /* added bitmask 32, correct?!?!?! */ , 0xFFFFFFFF }; +#endif void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size); void faad_endbits(bitfile *ld); @@ -83,6 +80,7 @@ uint8_t faad_byte_align(bitfile *ld); uint32_t faad_get_processed_bits(bitfile *ld); void faad_flushbits_ex(bitfile *ld, uint32_t bits); void faad_rewindbits(bitfile *ld); +void faad_resetbits(bitfile *ld, int bits); uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits DEBUGDEC); #ifdef DRM @@ -93,7 +91,6 @@ uint32_t faad_origbitbuffer_size(bitfile *ld); /* circumvent memory alignment errors on ARM */ static INLINE uint32_t getdword(void *mem) { -#ifdef ARM uint32_t tmp; #ifndef ARCH_IS_BIG_ENDIAN ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[3]; @@ -108,25 +105,52 @@ static INLINE uint32_t getdword(void *mem) #endif return tmp; -#else - uint32_t tmp; - tmp = *(uint32_t*)mem; +} + +/* reads only n bytes from the stream instead of the standard 4 */ +static /*INLINE*/ uint32_t getdword_n(void *mem, int n) +{ + uint32_t tmp = 0; #ifndef ARCH_IS_BIG_ENDIAN - BSWAP(tmp); + switch (n) + { + case 3: + ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[2]; + case 2: + ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[1]; + case 1: + ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[0]; + default: + break; + } +#else + switch (n) + { + case 3: + ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2]; + case 2: + ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1]; + case 1: + ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0]; + default: + break; + } #endif + return tmp; -#endif } static INLINE uint32_t faad_showbits(bitfile *ld, uint32_t bits) { if (bits <= ld->bits_left) { - return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits]; + //return (ld->bufa >> (ld->bits_left - bits)) & bitmask[bits]; + return (ld->bufa << (32 - ld->bits_left)) >> (32 - bits); } bits -= ld->bits_left; - return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits)); + //return ((ld->bufa & bitmask[ld->bits_left]) << bits) | (ld->bufb >> (32 - bits)); + return ((ld->bufa & ((1<bits_left)-1)) << bits) | (ld->bufb >> (32 - bits)); } static INLINE void faad_flushbits(bitfile *ld, uint32_t bits) @@ -144,11 +168,11 @@ static INLINE void faad_flushbits(bitfile *ld, uint32_t bits) } /* return next n bits (right adjusted) */ -static INLINE uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC) +static /*INLINE*/ uint32_t faad_getbits(bitfile *ld, uint32_t n DEBUGDEC) { uint32_t ret; - if (ld->no_more_reading || n == 0) + if (n == 0) return 0; ret = faad_showbits(ld, n); @@ -230,22 +254,23 @@ static INLINE void faad_flushbits_rev(bitfile *ld, uint32_t bits) ld->start--; ld->bits_left += (32 - bits); - ld->bytes_used += 4; - if (ld->bytes_used == ld->buffer_size) - ld->no_more_reading = 1; - if (ld->bytes_used > ld->buffer_size) + if (ld->bytes_left < 4) + { ld->error = 1; + ld->bytes_left = 0; + } else { + ld->bytes_left -= 4; + } +// if (ld->bytes_left == 0) +// ld->no_more_reading = 1; } } -static INLINE uint32_t faad_getbits_rev(bitfile *ld, uint32_t n +static /*INLINE*/ uint32_t faad_getbits_rev(bitfile *ld, uint32_t n DEBUGDEC) { uint32_t ret; - if (ld->no_more_reading) - return 0; - if (n == 0) return 0; @@ -261,28 +286,73 @@ static INLINE uint32_t faad_getbits_rev(bitfile *ld, uint32_t n } #ifdef DRM +/* CRC lookup table for G8 polynome in DRM standard */ +static const uint8_t crc_table_G8[256] = { + 0x0, 0x1d, 0x3a, 0x27, 0x74, 0x69, 0x4e, 0x53, + 0xe8, 0xf5, 0xd2, 0xcf, 0x9c, 0x81, 0xa6, 0xbb, + 0xcd, 0xd0, 0xf7, 0xea, 0xb9, 0xa4, 0x83, 0x9e, + 0x25, 0x38, 0x1f, 0x2, 0x51, 0x4c, 0x6b, 0x76, + 0x87, 0x9a, 0xbd, 0xa0, 0xf3, 0xee, 0xc9, 0xd4, + 0x6f, 0x72, 0x55, 0x48, 0x1b, 0x6, 0x21, 0x3c, + 0x4a, 0x57, 0x70, 0x6d, 0x3e, 0x23, 0x4, 0x19, + 0xa2, 0xbf, 0x98, 0x85, 0xd6, 0xcb, 0xec, 0xf1, + 0x13, 0xe, 0x29, 0x34, 0x67, 0x7a, 0x5d, 0x40, + 0xfb, 0xe6, 0xc1, 0xdc, 0x8f, 0x92, 0xb5, 0xa8, + 0xde, 0xc3, 0xe4, 0xf9, 0xaa, 0xb7, 0x90, 0x8d, + 0x36, 0x2b, 0xc, 0x11, 0x42, 0x5f, 0x78, 0x65, + 0x94, 0x89, 0xae, 0xb3, 0xe0, 0xfd, 0xda, 0xc7, + 0x7c, 0x61, 0x46, 0x5b, 0x8, 0x15, 0x32, 0x2f, + 0x59, 0x44, 0x63, 0x7e, 0x2d, 0x30, 0x17, 0xa, + 0xb1, 0xac, 0x8b, 0x96, 0xc5, 0xd8, 0xff, 0xe2, + 0x26, 0x3b, 0x1c, 0x1, 0x52, 0x4f, 0x68, 0x75, + 0xce, 0xd3, 0xf4, 0xe9, 0xba, 0xa7, 0x80, 0x9d, + 0xeb, 0xf6, 0xd1, 0xcc, 0x9f, 0x82, 0xa5, 0xb8, + 0x3, 0x1e, 0x39, 0x24, 0x77, 0x6a, 0x4d, 0x50, + 0xa1, 0xbc, 0x9b, 0x86, 0xd5, 0xc8, 0xef, 0xf2, + 0x49, 0x54, 0x73, 0x6e, 0x3d, 0x20, 0x7, 0x1a, + 0x6c, 0x71, 0x56, 0x4b, 0x18, 0x5, 0x22, 0x3f, + 0x84, 0x99, 0xbe, 0xa3, 0xf0, 0xed, 0xca, 0xd7, + 0x35, 0x28, 0xf, 0x12, 0x41, 0x5c, 0x7b, 0x66, + 0xdd, 0xc0, 0xe7, 0xfa, 0xa9, 0xb4, 0x93, 0x8e, + 0xf8, 0xe5, 0xc2, 0xdf, 0x8c, 0x91, 0xb6, 0xab, + 0x10, 0xd, 0x2a, 0x37, 0x64, 0x79, 0x5e, 0x43, + 0xb2, 0xaf, 0x88, 0x95, 0xc6, 0xdb, 0xfc, 0xe1, + 0x5a, 0x47, 0x60, 0x7d, 0x2e, 0x33, 0x14, 0x9, + 0x7f, 0x62, 0x45, 0x58, 0xb, 0x16, 0x31, 0x2c, + 0x97, 0x8a, 0xad, 0xb0, 0xe3, 0xfe, 0xd9, 0xc4, +}; + static uint8_t faad_check_CRC(bitfile *ld, uint16_t len) { - uint8_t CRC; - uint16_t r=255; /* Initialize to all ones */ + int bytes, rem; + unsigned int CRC; + unsigned int r=255; /* Initialize to all ones */ /* CRC polynome used x^8 + x^4 + x^3 + x^2 +1 */ #define GPOLY 0435 faad_rewindbits(ld); - CRC = (uint8_t) ~faad_getbits(ld, 8 - DEBUGVAR(1,999,"faad_check_CRC(): CRC")); /* CRC is stored inverted */ + CRC = (unsigned int) ~faad_getbits(ld, 8 + DEBUGVAR(1,999,"faad_check_CRC(): CRC")) & 0xFF; /* CRC is stored inverted */ + + bytes = len >> 3; + rem = len & 0x7; - for (; len>0; len--) + for (; bytes > 0; bytes--) + { + r = crc_table_G8[( r ^ faad_getbits(ld, 8 DEBUGVAR(1,998,"")) ) & 0xFF]; + } + for (; rem > 0; rem--) { r = ( (r << 1) ^ (( ( faad_get1bit(ld DEBUGVAR(1,998,"")) & 1) ^ ((r >> 7) & 1)) * GPOLY )) & 0xFF; } if (r != CRC) + // if (0) { - return 8; + return 28; } else { return 0; } diff --git a/src/libfaad/cfft.c b/src/libfaad/cfft.c index 61cac2fd5..5b01d75d3 100644 --- a/src/libfaad/cfft.c +++ b/src/libfaad/cfft.c @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: cfft.c,v 1.12 2006/09/26 18:00:31 dgp85 Exp $ +** $Id: cfft.c,v 1.35 2007/11/01 12:33:29 menno Exp $ **/ /* @@ -546,7 +549,7 @@ static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc, ComplexMult(&RE(c4), &RE(c5), ti12, ti11, RE(t5), RE(t4)); ComplexMult(&IM(c4), &IM(c5), - ti12, ti12, IM(t5), IM(t4)); + ti12, ti11, IM(t5), IM(t4)); RE(ch[ah+l1]) = RE(c2) + IM(c5); IM(ch[ah+l1]) = IM(c2) - RE(c5); @@ -648,7 +651,7 @@ static void passf5(const uint16_t ido, const uint16_t l1, const complex_t *cc, ComplexMult(&RE(c4), &RE(c5), ti12, ti11, RE(t5), RE(t4)); ComplexMult(&IM(c4), &IM(c5), - ti12, ti12, IM(t5), IM(t4)); + ti12, ti11, IM(t5), IM(t4)); IM(d2) = IM(c2) - RE(c5); IM(d3) = IM(c3) - RE(c4); @@ -992,13 +995,11 @@ cfft_info *cffti(uint16_t n) void cfftu(cfft_info *cfft) { - if ( ! cfft ) return; - - faad_free(cfft->work); + if (cfft->work) faad_free(cfft->work); #ifndef FIXED_POINT - faad_free(cfft->tab); + if (cfft->tab) faad_free(cfft->tab); #endif - faad_free(cfft); + if (cfft) faad_free(cfft); } diff --git a/src/libfaad/cfft.h b/src/libfaad/cfft.h index a29537bed..dc89cdc85 100644 --- a/src/libfaad/cfft.h +++ b/src/libfaad/cfft.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: cfft.h,v 1.9 2005/10/29 23:57:06 tmmm Exp $ +** $Id: cfft.h,v 1.24 2007/11/01 12:33:29 menno Exp $ **/ #ifndef __CFFT_H__ diff --git a/src/libfaad/cfft_tab.h b/src/libfaad/cfft_tab.h index 072a991f1..80b1b75be 100644 --- a/src/libfaad/cfft_tab.h +++ b/src/libfaad/cfft_tab.h @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: cfft_tab.h,v 1.6 2005/10/29 23:57:06 tmmm Exp $ +** $Id: cfft_tab.h,v 1.21 2007/11/01 12:33:29 menno Exp $ **/ #ifndef __CFFT_TAB_H__ diff --git a/src/libfaad/codebook/hcb.h b/src/libfaad/codebook/hcb.h index 96093300c..29bbca4f8 100644 --- a/src/libfaad/codebook/hcb.h +++ b/src/libfaad/codebook/hcb.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb.h,v 1.6 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb.h,v 1.8 2007/11/01 12:34:10 menno Exp $ **/ #ifndef __HCB_H__ diff --git a/src/libfaad/codebook/hcb_1.h b/src/libfaad/codebook/hcb_1.h index 220299c55..f6632c230 100644 --- a/src/libfaad/codebook/hcb_1.h +++ b/src/libfaad/codebook/hcb_1.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_1.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_1.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* 2-step huffman table HCB_1 */ diff --git a/src/libfaad/codebook/hcb_10.h b/src/libfaad/codebook/hcb_10.h index 60bcab90a..87e621df5 100644 --- a/src/libfaad/codebook/hcb_10.h +++ b/src/libfaad/codebook/hcb_10.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_10.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_10.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* 2-step huffman table HCB_10 */ diff --git a/src/libfaad/codebook/hcb_11.h b/src/libfaad/codebook/hcb_11.h index bd4f647e6..509a1d684 100644 --- a/src/libfaad/codebook/hcb_11.h +++ b/src/libfaad/codebook/hcb_11.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_11.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_11.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* 2-step huffman table HCB_11 */ diff --git a/src/libfaad/codebook/hcb_2.h b/src/libfaad/codebook/hcb_2.h index 6aff6b12b..8edfe525d 100644 --- a/src/libfaad/codebook/hcb_2.h +++ b/src/libfaad/codebook/hcb_2.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_2.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_2.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* 2-step huffman table HCB_2 */ diff --git a/src/libfaad/codebook/hcb_3.h b/src/libfaad/codebook/hcb_3.h index 25b54da90..e9481e198 100644 --- a/src/libfaad/codebook/hcb_3.h +++ b/src/libfaad/codebook/hcb_3.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_3.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_3.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* Binary search huffman table HCB_3 */ diff --git a/src/libfaad/codebook/hcb_4.h b/src/libfaad/codebook/hcb_4.h index 9378b0980..c2b43e005 100644 --- a/src/libfaad/codebook/hcb_4.h +++ b/src/libfaad/codebook/hcb_4.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_4.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_4.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* 2-step huffman table HCB_4 */ diff --git a/src/libfaad/codebook/hcb_5.h b/src/libfaad/codebook/hcb_5.h index 7e50207e3..ca7c473bf 100644 --- a/src/libfaad/codebook/hcb_5.h +++ b/src/libfaad/codebook/hcb_5.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_5.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_5.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* Binary search huffman table HCB_5 */ diff --git a/src/libfaad/codebook/hcb_6.h b/src/libfaad/codebook/hcb_6.h index 12417d997..2181d63d5 100644 --- a/src/libfaad/codebook/hcb_6.h +++ b/src/libfaad/codebook/hcb_6.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_6.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_6.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* 2-step huffman table HCB_6 */ diff --git a/src/libfaad/codebook/hcb_7.h b/src/libfaad/codebook/hcb_7.h index e5392326d..54c85c11d 100644 --- a/src/libfaad/codebook/hcb_7.h +++ b/src/libfaad/codebook/hcb_7.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_7.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_7.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* Binary search huffman table HCB_7 */ diff --git a/src/libfaad/codebook/hcb_8.h b/src/libfaad/codebook/hcb_8.h index 951743bed..6e3f1009e 100644 --- a/src/libfaad/codebook/hcb_8.h +++ b/src/libfaad/codebook/hcb_8.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_8.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_8.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* 2-step huffman table HCB_8 */ diff --git a/src/libfaad/codebook/hcb_9.h b/src/libfaad/codebook/hcb_9.h index daccf6197..bdba2c222 100644 --- a/src/libfaad/codebook/hcb_9.h +++ b/src/libfaad/codebook/hcb_9.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_9.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_9.h,v 1.5 2007/11/01 12:34:11 menno Exp $ **/ /* Binary search huffman table HCB_9 */ diff --git a/src/libfaad/codebook/hcb_sf.h b/src/libfaad/codebook/hcb_sf.h index 494053177..3c02b3d84 100644 --- a/src/libfaad/codebook/hcb_sf.h +++ b/src/libfaad/codebook/hcb_sf.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_sf.h,v 1.4 2005/10/29 23:57:08 tmmm Exp $ +** $Id: hcb_sf.h,v 1.7 2007/11/01 12:34:11 menno Exp $ **/ /* Binary search huffman table HCB_SF */ diff --git a/src/libfaad/common.c b/src/libfaad/common.c index 8c0d93e95..595605586 100644 --- a/src/libfaad/common.c +++ b/src/libfaad/common.c @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: common.c,v 1.8 2005/10/29 23:57:06 tmmm Exp $ +** $Id: common.c,v 1.26 2007/11/01 12:33:30 menno Exp $ **/ /* just some common functions that could be used anywhere */ @@ -229,16 +232,16 @@ static uint32_t __r2 = 1; * which gives a period of 18.410.713.077.675.721.215. The result is the * XORed values of both generators. */ -uint32_t random_int(void) +uint32_t ne_rng(uint32_t *__r1, uint32_t *__r2) { uint32_t t1, t2, t3, t4; - t3 = t1 = __r1; t4 = t2 = __r2; // Parity calculation is done via table lookup, this is also available + t3 = t1 = *__r1; t4 = t2 = *__r2; // Parity calculation is done via table lookup, this is also available t1 &= 0xF5; t2 >>= 25; // on CPUs without parity, can be implemented in C and avoid unpredictable t1 = Parity [t1]; t2 &= 0x63; // jumps and slow rotate through the carry flag operations. t1 <<= 31; t2 = Parity [t2]; - return (__r1 = (t3 >> 1) | t1 ) ^ (__r2 = (t4 + t4) | t2 ); + return (*__r1 = (t3 >> 1) | t1 ) ^ (*__r2 = (t4 + t4) | t2 ); } uint32_t ones32(uint32_t x) diff --git a/src/libfaad/common.h b/src/libfaad/common.h index 31f07708a..4d2769526 100644 --- a/src/libfaad/common.h +++ b/src/libfaad/common.h @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: common.h,v 1.17 2006/06/17 20:43:57 dgp85 Exp $ +** $Id: common.h,v 1.72 2007/11/01 12:33:30 menno Exp $ **/ #ifndef __COMMON_H__ @@ -32,13 +35,16 @@ extern "C" { #endif -#ifdef __CYGWIN__ -#define __STRICT_ANSI__ +#ifdef HAVE_CONFIG_H +# include #endif -#include "config.h" - +#if 1 #define INLINE __inline +#else +#define INLINE inline +#endif + #if 0 //defined(_WIN32) && !defined(_WIN32_WCE) #define ALIGN __declspec(align(16)) #else @@ -63,10 +69,13 @@ extern "C" { /* Use if target platform has address generators with autoincrement */ //#define PREFER_POINTERS -#if defined(_WIN32_WCE) || defined(__arm__) +#ifdef _WIN32_WCE #define FIXED_POINT #endif +#ifdef __BFIN__ +#define FIXED_POINT +#endif #define ERROR_RESILIENCE @@ -79,8 +88,6 @@ extern "C" { #define LTP_DEC /* Allow decoding of LD profile AAC */ #define LD_DEC -/* Allow decoding of scalable profiles */ -//#define SCALABLE_DEC /* Allow decoding of Digital Radio Mondiale (DRM) */ //#define DRM //#define DRM_PS @@ -114,20 +121,25 @@ extern "C" { //#define SBR_LOW_POWER #define PS_DEC +#ifdef SBR_LOW_POWER +#undef PS_DEC +#endif + /* FIXED POINT: No MAIN decoding */ #ifdef FIXED_POINT # ifdef MAIN_DEC # undef MAIN_DEC # endif -# ifdef SBR_DEC -# undef SBR_DEC -# endif #endif // FIXED_POINT #ifdef DRM -# ifndef SCALABLE_DEC -# define SCALABLE_DEC +# ifndef ALLOW_SMALL_FRAMELENGTH +# define ALLOW_SMALL_FRAMELENGTH # endif +# undef LD_DEC +# undef LTP_DEC +# undef MAIN_DEC +# undef SSR_DEC #endif @@ -152,6 +164,23 @@ extern "C" { /* END COMPILE TIME DEFINITIONS */ +#if defined(_WIN32) && !defined(__MINGW32__) + +#include + +typedef unsigned __int64 uint64_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int8 uint8_t; +typedef __int64 int64_t; +typedef __int32 int32_t; +typedef __int16 int16_t; +typedef __int8 int8_t; +typedef float float32_t; + + +#else + #include #if HAVE_SYS_TYPES_H # include @@ -176,8 +205,6 @@ extern "C" { #if HAVE_STRINGS_H # include #endif - -/* precedence defining int-types by header files for all platforms */ #if HAVE_INTTYPES_H # include #else @@ -185,30 +212,23 @@ extern "C" { # include # else /* we need these... */ -# ifdef WIN32 -typedef unsigned __int64 uint64_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int8 uint8_t; -typedef __int64 int64_t; -typedef __int32 int32_t; -typedef __int16 int16_t; -typedef __int8 int8_t; -# else /* WIN32 */ -typedef float float32_t; +#ifndef __TCS__ typedef unsigned long long uint64_t; +typedef long long int64_t; +#else +typedef unsigned long uint64_t; +typedef long int64_t; +#endif typedef unsigned long uint32_t; typedef unsigned short uint16_t; typedef unsigned char uint8_t; -typedef long long int64_t; typedef long int32_t; typedef short int16_t; typedef char int8_t; -# endif /* WIN32 */ # endif #endif #if HAVE_UNISTD_H -# include +//# include #endif #ifndef HAVE_FLOAT32_T @@ -229,6 +249,8 @@ char *strchr(), *strrchr(); # endif #endif +#endif + #ifdef WORDS_BIGENDIAN #define ARCH_IS_BIG_ENDIAN #endif @@ -289,7 +311,6 @@ char *strchr(), *strrchr(); } -#ifndef HAVE_LRINTF #if defined(_WIN32) && !defined(__MINGW32__) #define HAS_LRINTF static INLINE int lrintf(float f) @@ -302,7 +323,9 @@ char *strchr(), *strrchr(); } return i; } - #elif (defined(__i386__) && defined(__GNUC__)) + #elif (defined(__i386__) && defined(__GNUC__) && \ + !defined(__CYGWIN__) && !defined(__MINGW32__)) + #ifndef HAVE_LRINTF #define HAS_LRINTF // from http://www.stereopsis.com/FPU.html static INLINE int lrintf(float f) @@ -315,8 +338,9 @@ char *strchr(), *strrchr(); : "m" (f)); return i; } + #endif /* HAVE_LRINTF */ #endif -#endif + #ifdef __ICL /* only Intel C compiler has fmath ??? */ @@ -331,8 +355,6 @@ char *strchr(), *strrchr(); #else -#include - #ifdef HAVE_LRINTF # define HAS_LRINTF # define _ISOC9X_SOURCE 1 @@ -341,6 +363,8 @@ char *strchr(), *strrchr(); # define __USE_ISOC99 1 #endif + #include + #ifdef HAVE_SINF # define sin sinf #error @@ -380,7 +404,7 @@ typedef real_t complex_t[2]; /* common functions */ uint8_t cpu_has_sse(void); -uint32_t random_int(void); +uint32_t ne_rng(uint32_t *__r1, uint32_t *__r2); uint32_t ones32(uint32_t x); uint32_t floor_log2(uint32_t x); uint32_t wl_min_lzc(uint32_t x); diff --git a/src/libfaad/decoder.c b/src/libfaad/decoder.c index 33aee247e..7fb4b1965 100644 --- a/src/libfaad/decoder.c +++ b/src/libfaad/decoder.c @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: decoder.c,v 1.10 2005/10/29 23:57:06 tmmm Exp $ +** $Id: decoder.c,v 1.111 2007/11/01 12:33:30 menno Exp $ **/ #include "common.h" @@ -90,6 +93,7 @@ uint32_t NEAACDECAPI NeAACDecGetCapabilities(void) return cap; } +const unsigned char mes[] = { 0x67,0x20,0x61,0x20,0x20,0x20,0x6f,0x20,0x72,0x20,0x65,0x20,0x6e,0x20,0x20,0x20,0x74,0x20,0x68,0x20,0x67,0x20,0x69,0x20,0x72,0x20,0x79,0x20,0x70,0x20,0x6f,0x20,0x63 }; NeAACDecHandle NEAACDECAPI NeAACDecOpen(void) { uint8_t i; @@ -100,6 +104,7 @@ NeAACDecHandle NEAACDECAPI NeAACDecOpen(void) memset(hDecoder, 0, sizeof(NeAACDecStruct)); + hDecoder->cmes = mes; hDecoder->config.outputFormat = FAAD_FMT_16BIT; hDecoder->config.defObjectType = MAIN; hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */ @@ -116,6 +121,9 @@ NeAACDecHandle NEAACDECAPI NeAACDecOpen(void) hDecoder->frame = 0; hDecoder->sample_buffer = NULL; + hDecoder->__r1 = 1; + hDecoder->__r2 = 1; + for (i = 0; i < MAX_CHANNELS; i++) { hDecoder->window_shape_prev[i] = 0; @@ -194,6 +202,7 @@ uint8_t NEAACDECAPI NeAACDecSetConfiguration(NeAACDecHandle hDecoder, return 0; } + int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, uint32_t buffer_size, uint32_t *samplerate, uint8_t *channels) @@ -203,6 +212,7 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, adif_header adif; adts_header adts; + if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL)) return -1; @@ -257,7 +267,6 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, } faad_endbits(&ld); } - hDecoder->channelConfiguration = *channels; #if (defined(PS_DEC) || defined(DRM_PS)) /* check if we have a mono file */ @@ -268,6 +277,8 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, } #endif + hDecoder->channelConfiguration = *channels; + #ifdef SBR_DEC /* implicit signalling */ if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) @@ -422,8 +433,8 @@ int8_t NEAACDECAPI NeAACDecInitDRM(NeAACDecHandle *hDecoder, uint32_t samplerate if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO)) (*hDecoder)->sbr_present_flag = 0; else - (*hDecoder)->sbr_present_flag = 1; -#endif + (*hDecoder)->sbr_present_flag = 1; +#endif (*hDecoder)->fb = filter_bank_init((*hDecoder)->frameLength); @@ -525,8 +536,14 @@ static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hI chdir = hInfo->num_front_channels; if (chdir & 1) { +#if (defined(PS_DEC) || defined(DRM_PS)) + /* When PS is enabled output is always stereo */ + hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT; +#else hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER; chdir--; +#endif } for (i = 0; i < chdir; i += 2) { @@ -565,8 +582,15 @@ static void create_channel_config(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hI switch (hDecoder->channelConfiguration) { case 1: +#if (defined(PS_DEC) || defined(DRM_PS)) + /* When PS is enabled output is always stereo */ + hInfo->num_front_channels = 2; + hInfo->channel_position[0] = FRONT_CHANNEL_LEFT; + hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT; +#else hInfo->num_front_channels = 1; hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; +#endif break; case 2: hInfo->num_front_channels = 2; @@ -722,13 +746,25 @@ void* NEAACDECAPI NeAACDecDecode2(NeAACDecHandle hDecoder, sample_buffer, sample_buffer_size); } +#ifdef DRM + +#define ERROR_STATE_INIT 6 + +static void conceal_output(NeAACDecHandle hDecoder, uint16_t frame_len, + uint8_t out_ch, void *sample_buffer) +{ + return; +} +#endif + static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, uint8_t *buffer, uint32_t buffer_size, void **sample_buffer2, uint32_t sample_buffer_size) { + uint16_t i; uint8_t channels = 0; uint8_t output_channels = 0; - bitfile ld; + bitfile ld = {0}; uint32_t bitsconsumed; uint16_t frame_len; void *sample_buffer; @@ -753,6 +789,33 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, memset(hInfo, 0, sizeof(NeAACDecFrameInfo)); memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0])); +#ifdef USE_TIME_LIMIT + if ((TIME_LIMIT * get_sample_rate(hDecoder->sf_index)) > hDecoder->TL_count) + { + hDecoder->TL_count += 1024; + } else { + hInfo->error = (NUM_ERROR_MESSAGES-1); + goto error; + } +#endif + + + /* check for some common metadata tag types in the bitstream + * No need to return an error + */ + /* ID3 */ + if (buffer_size >= 128) + { + if (memcmp(buffer, "TAG", 3) == 0) + { + /* found it */ + hInfo->bytesconsumed = 128; /* 128 bytes fixed size */ + /* no error, but no output either */ + return NULL; + } + } + + /* initialize the bitstream */ faad_initbits(&ld, buffer, buffer_size); @@ -780,7 +843,7 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, /* We do not support stereo right now */ if (0) //(hDecoder->channelConfiguration == 2) { - hInfo->error = 8; // Throw CRC error + hInfo->error = 28; // Throw CRC error goto error; } @@ -808,14 +871,14 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, #endif /* decode the complete bitstream */ -#ifdef SCALABLE_DEC - if ((hDecoder->object_type == 6) || (hDecoder->object_type == DRM_ER_LC)) +#ifdef DRM + if (/*(hDecoder->object_type == 6) ||*/ (hDecoder->object_type == DRM_ER_LC)) { - aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); + DRM_aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); } else { #endif raw_data_block(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); -#ifdef SCALABLE_DEC +#ifdef DRM } #endif @@ -978,10 +1041,16 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, } #endif + sample_buffer = output_to_PCM(hDecoder, hDecoder->time_out, sample_buffer, output_channels, frame_len, hDecoder->config.outputFormat); +#ifdef DRM + //conceal_output(hDecoder, frame_len, output_channels, sample_buffer); +#endif + + hDecoder->postSeekResetFlag = 0; hDecoder->frame++; @@ -1013,6 +1082,30 @@ static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, error: + +#ifdef DRM + hDecoder->error_state = ERROR_STATE_INIT; +#endif + + /* reset filterbank state */ + for (i = 0; i < MAX_CHANNELS; i++) + { + if (hDecoder->fb_intermed[i] != NULL) + { + memset(hDecoder->fb_intermed[i], 0, hDecoder->frameLength*sizeof(real_t)); + } + } +#ifdef SBR_DEC + for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) + { + if (hDecoder->sbr[i] != NULL) + { + sbrReset(hDecoder->sbr[i]); + } + } +#endif + + faad_endbits(&ld); /* cleanup */ diff --git a/src/libfaad/decoder.h b/src/libfaad/decoder.h index 5a3a2663f..a4cb567d2 100644 --- a/src/libfaad/decoder.h +++ b/src/libfaad/decoder.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: decoder.h,v 1.9 2005/10/29 23:57:06 tmmm Exp $ +** $Id: decoder.h,v 1.48 2007/11/01 12:33:30 menno Exp $ **/ #ifndef __DECODER_H__ diff --git a/src/libfaad/drc.c b/src/libfaad/drc.c index ef4b6a96e..3c9ff3ae0 100644 --- a/src/libfaad/drc.c +++ b/src/libfaad/drc.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: drc.c,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: drc.c,v 1.28 2007/11/01 12:33:30 menno Exp $ **/ #include "common.h" diff --git a/src/libfaad/drc.h b/src/libfaad/drc.h index 046ecbc3e..49118bcd0 100644 --- a/src/libfaad/drc.h +++ b/src/libfaad/drc.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: drc.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: drc.h,v 1.22 2007/11/01 12:33:30 menno Exp $ **/ #ifndef __DRC_H__ diff --git a/src/libfaad/drm_dec.c b/src/libfaad/drm_dec.c index a782b0f22..61cb8180e 100644 --- a/src/libfaad/drm_dec.c +++ b/src/libfaad/drm_dec.c @@ -1,28 +1,31 @@ /* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: drm_dec.c,v 1.1 2005/10/30 00:50:19 tmmm Exp $ +** $Id: drm_dec.c,v 1.9 2007/11/01 12:33:30 menno Exp $ **/ #include @@ -243,17 +246,9 @@ static const real_t sa_sqrt_1_minus[8][2] = { { FRAC_CONST(0.929071574), FRAC_CONST(0) } }; -static const uint8_t sa_freq_scale[9][2] = +static const uint8_t sa_freq_scale[9] = { - { 0, 0}, - { 1, 1}, - { 2, 2}, - { 3, 3}, - { 5, 5}, - { 7, 7}, - {10,10}, - {13,13}, - {46,23} + 0, 1, 2, 3, 5, 7, 10, 13, 23 }; static const uint8_t pan_freq_scale[21] = @@ -290,9 +285,9 @@ static const real_t filter_coeff[] = FRAC_CONST(0.48954165955695) }; -static const uint8_t delay_length[][2] = +static const uint8_t delay_length[3] = { - { 1, 3 }, { 2, 4 }, { 3, 5 } + 3, 4, 5 }; static const real_t delay_fraction[] = @@ -300,15 +295,9 @@ static const real_t delay_fraction[] = FRAC_CONST(0.43), FRAC_CONST(0.75), FRAC_CONST(0.347) }; -static const real_t peak_decay[2] = -{ - FRAC_CONST(0.58664621951003), FRAC_CONST(0.76592833836465) -}; +static const real_t peak_decay = FRAC_CONST(0.76592833836465); -static const real_t smooth_coeff[2] = -{ - FRAC_CONST(0.6), FRAC_CONST(0.25) -}; +static const real_t smooth_coeff = FRAC_CONST(0.25); /* Please note that these are the same tables as in plain PS */ static const complex_t Q_Fract_allpass_Qmf[][3] = { @@ -566,25 +555,22 @@ static void drm_ps_delta_decode(drm_ps_info *ps) { if (ps->bs_sa_dt_flag && !ps->g_last_had_sa) { - for (band = 0; band < DRM_NUM_SA_BANDS; band++) - { - ps->g_prev_sa_index[band] = 0; - } - } - if (ps->bs_sa_dt_flag) - { + /* wait until we get a DT frame */ + ps->bs_enable_sa = 0; + } else if (ps->bs_sa_dt_flag) { + /* DT frame, we have a last frame, so we can decode */ ps->g_sa_index[0] = sa_delta_clip(ps, ps->g_prev_sa_index[0]+ps->bs_sa_data[0]); - } else { + /* DF always decodable */ ps->g_sa_index[0] = sa_delta_clip(ps,ps->bs_sa_data[0]); } for (band = 1; band < DRM_NUM_SA_BANDS; band++) { - if (ps->bs_sa_dt_flag) + if (ps->bs_sa_dt_flag && ps->g_last_had_sa) { ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_prev_sa_index[band] + ps->bs_sa_data[band]); - } else { + } else if (!ps->bs_sa_dt_flag) { ps->g_sa_index[band] = sa_delta_clip(ps, ps->g_sa_index[band-1] + ps->bs_sa_data[band]); } } @@ -618,28 +604,19 @@ static void drm_ps_delta_decode(drm_ps_info *ps) { if (ps->bs_pan_dt_flag && !ps->g_last_had_pan) { -/* The DRM PS spec doesn't say anything about this case. (deltacoded in time without a previous frame) - AAC PS spec you must tread previous frame as 0, so that's what we try. -*/ - for (band = 0; band < DRM_NUM_PAN_BANDS; band++) - { - ps->g_prev_pan_index[band] = 0; - } - } - - if (ps->bs_pan_dt_flag) - { - ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]); + ps->bs_enable_pan = 0; + } else if (ps->bs_pan_dt_flag) { + ps->g_pan_index[0] = pan_delta_clip(ps, ps->g_prev_pan_index[0]+ps->bs_pan_data[0]); } else { - ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]); + ps->g_pan_index[0] = pan_delta_clip(ps, ps->bs_pan_data[0]); } for (band = 1; band < DRM_NUM_PAN_BANDS; band++) { - if (ps->bs_pan_dt_flag) + if (ps->bs_pan_dt_flag && ps->g_last_had_pan) { ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_prev_pan_index[band] + ps->bs_pan_data[band]); - } else { + } else if (!ps->bs_pan_dt_flag) { ps->g_pan_index[band] = pan_delta_clip(ps, ps->g_pan_index[band-1] + ps->bs_pan_data[band]); } } @@ -658,7 +635,7 @@ static void drm_ps_delta_decode(drm_ps_info *ps) } } -static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t rateselect) +static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64]) { uint8_t s, b, k; complex_t qfrac, tmp0, tmp, in, R0; @@ -673,7 +650,7 @@ static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t ra uint32_t in_re, in_im; #endif - for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) + for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++) { /* set delay indices */ for (k = 0; k < NUM_OF_LINKS; k++) @@ -701,16 +678,16 @@ static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t ra power = MUL_R(RE(in),RE(in)) + MUL_R(IM(in),IM(in)); #endif - ps->peakdecay_fast[b] = MUL_F(ps->peakdecay_fast[b], peak_decay[rateselect]); + ps->peakdecay_fast[b] = MUL_F(ps->peakdecay_fast[b], peak_decay); if (ps->peakdecay_fast[b] < power) ps->peakdecay_fast[b] = power; peakdiff = ps->prev_peakdiff[b]; - peakdiff += MUL_F((ps->peakdecay_fast[b] - power - ps->prev_peakdiff[b]), smooth_coeff[rateselect]); + peakdiff += MUL_F((ps->peakdecay_fast[b] - power - ps->prev_peakdiff[b]), smooth_coeff); ps->prev_peakdiff[b] = peakdiff; nrg = ps->prev_nrg[b]; - nrg += MUL_F((power - ps->prev_nrg[b]), smooth_coeff[rateselect]); + nrg += MUL_F((power - ps->prev_nrg[b]), smooth_coeff); ps->prev_nrg[b] = nrg; if (MUL_R(peakdiff, gamma) <= nrg) { @@ -763,7 +740,7 @@ static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t ra for (k = 0; k < NUM_OF_LINKS; k++) { - if (++temp_delay_ser[k] >= delay_length[k][rateselect]) + if (++temp_delay_ser[k] >= delay_length[k]) temp_delay_ser[k] = 0; } } @@ -773,7 +750,7 @@ static void drm_calc_sa_side_signal(drm_ps_info *ps, qmf_t X[38][64], uint8_t ra ps->delay_buf_index_ser[k] = temp_delay_ser[k]; } -static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64]) +static void drm_add_ambiance(drm_ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]) { uint8_t s, b, ifreq, qclass; real_t sa_map[MAX_SA_BAND], sa_dir_map[MAX_SA_BAND], k_sa_map[MAX_SA_BAND], k_sa_dir_map[MAX_SA_BAND]; @@ -783,7 +760,7 @@ static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[3 { /* Instead of dequantization and mapping, we use an inverse mapping to look up all the values we need */ - for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) + for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++) { const real_t inv_f_num_of_subsamples = FRAC_CONST(0.03333333333); @@ -804,7 +781,7 @@ static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[3 for (s = 0; s < NUM_OF_SUBSAMPLES; s++) { - for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b++) + for (b = 0; b < sa_freq_scale[DRM_NUM_SA_BANDS]; b++) { QMF_RE(X_right[s][b]) = MUL_F(QMF_RE(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_RE(ps->SA[s][b]), sa_map[b]); QMF_IM(X_right[s][b]) = MUL_F(QMF_IM(X_left[s][b]), sa_dir_map[b]) - MUL_F(QMF_IM(ps->SA[s][b]), sa_map[b]); @@ -814,7 +791,7 @@ static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[3 sa_map[b] += k_sa_map[b]; sa_dir_map[b] += k_sa_dir_map[b]; } - for (b = sa_freq_scale[DRM_NUM_SA_BANDS][rateselect]; b < NUM_OF_QMF_CHANNELS; b++) + for (b = sa_freq_scale[DRM_NUM_SA_BANDS]; b < NUM_OF_QMF_CHANNELS; b++) { QMF_RE(X_right[s][b]) = QMF_RE(X_left[s][b]); QMF_IM(X_right[s][b]) = QMF_IM(X_left[s][b]); @@ -833,7 +810,7 @@ static void drm_add_ambiance(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[3 } } -static void drm_add_pan(drm_ps_info *ps, uint8_t rateselect, qmf_t X_left[38][64], qmf_t X_right[38][64]) +static void drm_add_pan(drm_ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]) { uint8_t s, b, qclass, ifreq; real_t tmp, coeff1, coeff2; @@ -924,10 +901,8 @@ void drm_ps_free(drm_ps_info *ps) } /* main DRM PS decoding function */ -uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, qmf_t X_left[38][64], qmf_t X_right[38][64]) -{ - uint8_t rateselect = (samplerate >= 24000); - +uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]) +{ if (ps == NULL) { memcpy(X_right, X_left, sizeof(qmf_t)*30*64); @@ -958,8 +933,8 @@ uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, qmf_t ps->drm_ps_data_available = 0; - drm_calc_sa_side_signal(ps, X_left, rateselect); - drm_add_ambiance(ps, rateselect, X_left, X_right); + drm_calc_sa_side_signal(ps, X_left); + drm_add_ambiance(ps, X_left, X_right); if (ps->bs_enable_sa) { @@ -973,7 +948,7 @@ uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, qmf_t if (ps->bs_enable_pan) { - drm_add_pan(ps, rateselect, X_left, X_right); + drm_add_pan(ps, X_left, X_right); ps->g_last_had_pan = 1; diff --git a/src/libfaad/drm_dec.h b/src/libfaad/drm_dec.h index bb7d6dc93..d0ac995e4 100644 --- a/src/libfaad/drm_dec.h +++ b/src/libfaad/drm_dec.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: drm_dec.h,v 1.1 2005/10/30 00:50:19 tmmm Exp $ +** $Id: drm_dec.h,v 1.8 2007/11/01 12:33:30 menno Exp $ **/ #ifndef __DRM_DEC_H__ @@ -88,7 +91,7 @@ uint16_t drm_ps_data(drm_ps_info *ps, bitfile *ld); drm_ps_info *drm_ps_init(void); void drm_ps_free(drm_ps_info *ps); -uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, uint32_t samplerate, qmf_t X_left[38][64], qmf_t X_right[38][64]); +uint8_t drm_ps_decode(drm_ps_info *ps, uint8_t guess, qmf_t X_left[38][64], qmf_t X_right[38][64]); #ifdef __cplusplus } diff --git a/src/libfaad/error.c b/src/libfaad/error.c index 2fbe08fc1..c552e06cd 100644 --- a/src/libfaad/error.c +++ b/src/libfaad/error.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: error.c,v 1.8 2005/10/29 23:57:06 tmmm Exp $ +** $Id: error.c,v 1.32 2007/11/01 12:33:30 menno Exp $ **/ #include "common.h" @@ -56,6 +59,11 @@ char *err_msg[] = { "Unexpected fill element with SBR data", "Not all elements were provided with SBR data", "LTP decoding not available", - "Output data buffer too small" + "Output data buffer too small", + "CRC error in DRM data", + "PNS not allowed in DRM data stream", + "No standard extension payload allowed in DRM", + "PCE shall be the first element in a frame", + "Bitstream value not allowed by specification" }; diff --git a/src/libfaad/error.h b/src/libfaad/error.h index 1009a9f57..7f750217c 100644 --- a/src/libfaad/error.h +++ b/src/libfaad/error.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: error.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: error.h,v 1.26 2007/11/01 12:33:30 menno Exp $ **/ #ifndef __ERROR_H__ @@ -32,7 +35,7 @@ extern "C" { #endif -#define NUM_ERROR_MESSAGES 28 +#define NUM_ERROR_MESSAGES 33 extern char *err_msg[]; #ifdef __cplusplus diff --git a/src/libfaad/filtbank.c b/src/libfaad/filtbank.c index 2919b5be3..eaeddcce6 100644 --- a/src/libfaad/filtbank.c +++ b/src/libfaad/filtbank.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: filtbank.c,v 1.10 2005/10/29 23:57:06 tmmm Exp $ +** $Id: filtbank.c,v 1.45 2007/11/01 12:33:30 menno Exp $ **/ #include "common.h" diff --git a/src/libfaad/filtbank.h b/src/libfaad/filtbank.h index 54c72c0ef..de0149c97 100644 --- a/src/libfaad/filtbank.h +++ b/src/libfaad/filtbank.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: filtbank.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: filtbank.h,v 1.27 2007/11/01 12:33:30 menno Exp $ **/ #ifndef __FILTBANK_H__ diff --git a/src/libfaad/fixed.h b/src/libfaad/fixed.h index c58ee26cb..531583772 100644 --- a/src/libfaad/fixed.h +++ b/src/libfaad/fixed.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: fixed.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: fixed.h,v 1.32 2007/11/01 12:33:30 menno Exp $ **/ #ifndef __FIXED_H__ @@ -36,6 +39,7 @@ extern "C" { #include #endif + #define COEF_BITS 28 #define COEF_PRECISION (1 << COEF_BITS) #define REAL_BITS 14 // MAXIMUM OF 14 FOR FIXED POINT SBR @@ -239,9 +243,27 @@ static INLINE void ComplexMult(real_t *y1, real_t *y2, { return _MulHigh(A,B) << (32-FRAC_BITS); } +#else +#ifdef __BFIN__ +#define _MulHigh(X,Y) ({ int __xxo; \ + asm ( \ + "a1 = %2.H * %1.L (IS,M);\n\t" \ + "a0 = %1.H * %2.H, a1+= %1.H * %2.L (IS,M);\n\t"\ + "a1 = a1 >>> 16;\n\t" \ + "%0 = (a0 += a1);\n\t" \ + : "=d" (__xxo) : "d" (X), "d" (Y) : "A0","A1"); __xxo; }) + +#define MUL_F(X,Y) ({ int __xxo; \ + asm ( \ + "a1 = %2.H * %1.L (M);\n\t" \ + "a0 = %1.H * %2.H, a1+= %1.H * %2.L (M);\n\t" \ + "a1 = a1 >>> 16;\n\t" \ + "%0 = (a0 += a1);\n\t" \ + : "=d" (__xxo) : "d" (X), "d" (Y) : "A0","A1"); __xxo; }) #else #define _MulHigh(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_SIZE-1))) >> FRAC_SIZE) #define MUL_F(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (FRAC_BITS-1))) >> FRAC_BITS) +#endif #endif #define MUL_Q2(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (Q2_BITS-1))) >> Q2_BITS) #define MUL_SHIFT6(A,B) (real_t)(((int64_t)(A)*(int64_t)(B)+(1 << (6-1))) >> 6) diff --git a/src/libfaad/hcr.c b/src/libfaad/hcr.c index 94f08fd2a..c76629641 100644 --- a/src/libfaad/hcr.c +++ b/src/libfaad/hcr.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2004 G.C. Pascutto, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: hcr.c,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: hcr.c,v 1.24 2007/11/01 12:33:30 menno Exp $ **/ #include "common.h" @@ -222,6 +225,7 @@ uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, uint16_t sp_offset[8]; uint16_t g, i, sortloop, set, bitsread; + uint16_t bitsleft, codewordsleft; uint8_t w_idx, sfb, this_CB, last_CB, this_sec_CB; const uint16_t nshort = hDecoder->frameLength/8; @@ -236,7 +240,7 @@ uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, /* since there is spectral data, at least one codeword has nonzero length */ if (ics->length_of_longest_codeword == 0) return 10; - + if (sp_data_len < ics->length_of_longest_codeword) return 10; @@ -272,7 +276,7 @@ uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, for (sfb = 0; sfb < ics->max_sfb; sfb++) { /* loop over all in this sfb, 4 lines per loop */ - for (w_idx = 0; 4*w_idx < (ics->swb_offset[sfb+1] - ics->swb_offset[sfb]); w_idx++) + for (w_idx = 0; 4*w_idx < (min(ics->swb_offset[sfb+1], ics->swb_offset_max) - ics->swb_offset[sfb]); w_idx++) { for(g = 0; g < ics->num_window_groups; g++) { @@ -404,6 +408,25 @@ uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, rewrev_bits(&segment[i]); } +#if 0 // Seems to give false errors + bitsleft = 0; + + for (i = 0; i < numberOfSegments && !bitsleft; i++) + bitsleft += segment[i].len; + + if (bitsleft) return 10; + + codewordsleft = 0; + + for (i = 0; (i < numberOfCodewords - numberOfSegments) && (!codewordsleft); i++) + if (!codeword[i].decoded) + codewordsleft++; + + if (codewordsleft) return 10; +#endif + + return 0; + } #endif diff --git a/src/libfaad/huffman.c b/src/libfaad/huffman.c index 6c24a6cec..e2656c089 100644 --- a/src/libfaad/huffman.c +++ b/src/libfaad/huffman.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: huffman.c,v 1.5 2005/10/29 23:57:06 tmmm Exp $ +** $Id: huffman.c,v 1.26 2007/11/01 12:33:30 menno Exp $ **/ #include "common.h" diff --git a/src/libfaad/huffman.h b/src/libfaad/huffman.h index cffe23093..f8bcb237e 100644 --- a/src/libfaad/huffman.h +++ b/src/libfaad/huffman.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: huffman.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: huffman.h,v 1.28 2007/11/01 12:33:30 menno Exp $ **/ #ifndef __HUFFMAN_H__ diff --git a/src/libfaad/ic_predict.c b/src/libfaad/ic_predict.c index 82753a9f2..70027ba2f 100644 --- a/src/libfaad/ic_predict.c +++ b/src/libfaad/ic_predict.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ic_predict.c,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: ic_predict.c,v 1.28 2007/11/01 12:33:31 menno Exp $ **/ #include "common.h" @@ -81,7 +84,8 @@ static void ic_predict(pred_state *state, real_t input, real_t *output, uint8_t { uint16_t tmp; int16_t i, j; - real_t dr1, predictedvalue; + real_t dr1; + float32_t predictedvalue; real_t e0, e1; real_t k1, k2; @@ -114,7 +118,7 @@ static void ic_predict(pred_state *state, real_t input, real_t *output, uint8_t #define B 0.953125 real_t c = COR[0]; real_t v = VAR[0]; - real_t tmp; + float32_t tmp; if (c == 0 || v <= 1) { k1 = 0; @@ -144,7 +148,7 @@ static void ic_predict(pred_state *state, real_t input, real_t *output, uint8_t #define B 0.953125 real_t c = COR[1]; real_t v = VAR[1]; - real_t tmp; + float32_t tmp; if (c == 0 || v <= 1) { k2 = 0; @@ -209,7 +213,7 @@ void pns_reset_pred_state(ic_stream *ics, pred_state *state) if (is_noise(ics, g, sfb)) { offs = ics->swb_offset[sfb]; - offs2 = ics->swb_offset[sfb+1]; + offs2 = min(ics->swb_offset[sfb+1], ics->swb_offset_max); for (i = offs; i < offs2; i++) reset_pred_state(&state[i]); @@ -241,7 +245,7 @@ void ic_prediction(ic_stream *ics, real_t *spec, pred_state *state, for (sfb = 0; sfb < max_pred_sfb(sf_index); sfb++) { uint16_t low = ics->swb_offset[sfb]; - uint16_t high = ics->swb_offset[sfb+1]; + uint16_t high = min(ics->swb_offset[sfb+1], ics->swb_offset_max); for (bin = low; bin < high; bin++) { diff --git a/src/libfaad/ic_predict.h b/src/libfaad/ic_predict.h index 233992b96..e69cd114e 100644 --- a/src/libfaad/ic_predict.h +++ b/src/libfaad/ic_predict.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ic_predict.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: ic_predict.h,v 1.23 2007/11/01 12:33:31 menno Exp $ **/ #ifdef MAIN_DEC diff --git a/src/libfaad/iq_table.h b/src/libfaad/iq_table.h index 9002e15d7..3cc2b8061 100644 --- a/src/libfaad/iq_table.h +++ b/src/libfaad/iq_table.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: iq_table.h,v 1.6 2005/10/29 23:57:06 tmmm Exp $ +** $Id: iq_table.h,v 1.20 2007/11/01 12:33:31 menno Exp $ **/ #ifndef IQ_TABLE_H__ diff --git a/src/libfaad/is.c b/src/libfaad/is.c index 9fcdbcbb5..5236db077 100644 --- a/src/libfaad/is.c +++ b/src/libfaad/is.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: is.c,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: is.c,v 1.28 2007/11/01 12:33:31 menno Exp $ **/ #include "common.h" @@ -84,7 +87,7 @@ void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, /* Scale from left to right channel, do not touch left channel */ - for (i = icsr->swb_offset[sfb]; i < icsr->swb_offset[sfb+1]; i++) + for (i = icsr->swb_offset[sfb]; i < min(icsr->swb_offset[sfb+1], ics->swb_offset_max); i++) { #ifndef FIXED_POINT r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale); diff --git a/src/libfaad/is.h b/src/libfaad/is.h index 0786f7258..3e3b750ab 100644 --- a/src/libfaad/is.h +++ b/src/libfaad/is.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: is.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: is.h,v 1.20 2007/11/01 12:33:31 menno Exp $ **/ #ifndef __IS_H__ diff --git a/src/libfaad/kbd_win.h b/src/libfaad/kbd_win.h index 046b6b995..de404c7ea 100644 --- a/src/libfaad/kbd_win.h +++ b/src/libfaad/kbd_win.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: kbd_win.h,v 1.7 2005/10/29 23:57:06 tmmm Exp $ +** $Id: kbd_win.h,v 1.21 2007/11/01 12:33:31 menno Exp $ **/ #ifndef __KBD_WIN_H__ diff --git a/src/libfaad/lt_predict.c b/src/libfaad/lt_predict.c index 3aab00426..2be18ae9f 100644 --- a/src/libfaad/lt_predict.c +++ b/src/libfaad/lt_predict.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: lt_predict.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: lt_predict.c,v 1.27 2007/11/01 12:33:31 menno Exp $ **/ @@ -52,9 +55,6 @@ uint8_t is_ltp_ot(uint8_t object_type) #endif #ifdef LD_DEC || (object_type == LD) -#endif -#ifdef SCALABLE_DEC - || (object_type == 6) /* TODO */ #endif ) { @@ -120,7 +120,7 @@ void lt_prediction(ic_stream *ics, ltp_info *ltp, real_t *spec, if (ltp->long_used[sfb]) { uint16_t low = ics->swb_offset[sfb]; - uint16_t high = ics->swb_offset[sfb+1]; + uint16_t high = min(ics->swb_offset[sfb+1], ics->swb_offset_max); for (bin = low; bin < high; bin++) { diff --git a/src/libfaad/lt_predict.h b/src/libfaad/lt_predict.h index faa2fbca7..117f83424 100644 --- a/src/libfaad/lt_predict.h +++ b/src/libfaad/lt_predict.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: lt_predict.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: lt_predict.h,v 1.20 2007/11/01 12:33:31 menno Exp $ **/ #ifdef LTP_DEC diff --git a/src/libfaad/mdct.c b/src/libfaad/mdct.c index 0df3d6aae..247691e40 100644 --- a/src/libfaad/mdct.c +++ b/src/libfaad/mdct.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: mdct.c,v 1.11 2005/10/29 23:57:07 tmmm Exp $ +** $Id: mdct.c,v 1.47 2007/11/01 12:33:31 menno Exp $ **/ /* @@ -33,7 +36,7 @@ * As described in: * P. Duhamel, Y. Mahieux, and J.P. Petit, "A Fast Algorithm for the * Implementation of Filter Banks Based on 'Time Domain Aliasing - * Cancellation'," IEEE Proc. on ICASSP'91, 1991, pp. 2209-2212. + * Cancellation’," IEEE Proc. on ICASSP‘91, 1991, pp. 2209-2212. * * * As of April 6th 2002 completely rewritten. diff --git a/src/libfaad/mdct.h b/src/libfaad/mdct.h index c2b738795..736180ead 100644 --- a/src/libfaad/mdct.h +++ b/src/libfaad/mdct.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: mdct.h,v 1.8 2005/10/29 23:57:07 tmmm Exp $ +** $Id: mdct.h,v 1.30 2007/11/01 12:33:31 menno Exp $ **/ #ifndef __MDCT_H__ diff --git a/src/libfaad/mdct_tab.h b/src/libfaad/mdct_tab.h index 7dd17166b..eea285b67 100644 --- a/src/libfaad/mdct_tab.h +++ b/src/libfaad/mdct_tab.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: mdct_tab.h,v 1.1 2005/10/30 00:50:19 tmmm Exp $ +** $Id: mdct_tab.h,v 1.7 2007/11/01 12:33:32 menno Exp $ **/ #ifndef __MDCT_TAB_H__ diff --git a/src/libfaad/mp4.c b/src/libfaad/mp4.c index 651280805..ef3f8a9c9 100644 --- a/src/libfaad/mp4.c +++ b/src/libfaad/mp4.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: mp4.c,v 1.9 2005/10/29 23:57:07 tmmm Exp $ +** $Id: mp4.c,v 1.38 2007/11/01 12:33:32 menno Exp $ **/ #include "common.h" @@ -58,11 +61,7 @@ static uint8_t ObjectTypesTable[32] = { #else 0, /* 5 SBR */ #endif -#ifdef SCALABLE_DEC - 1, /* 6 AAC Scalable */ -#else 0, /* 6 AAC Scalable */ -#endif 0, /* 7 TwinVQ */ 0, /* 8 CELP */ 0, /* 9 HVXC */ @@ -83,11 +82,7 @@ static uint8_t ObjectTypesTable[32] = { #else 0, /* 19 ER AAC LTP */ #endif -#ifdef SCALABLE_DEC - 1, /* 20 ER AAC scalable */ -#else 0, /* 20 ER AAC scalable */ -#endif 0, /* 21 ER TwinVQ */ 0, /* 22 ER BSAC */ #ifdef LD_DEC @@ -248,10 +243,10 @@ int8_t AudioSpecificConfig2(uint8_t *pBuffer, if (syncExtensionType == 0x2b7) { - mp4ASC->objectTypeIndex = (uint8_t)faad_getbits(&ld, 5 + uint8_t tmp_OTi = (uint8_t)faad_getbits(&ld, 5 DEBUGVAR(1,10,"parse_audio_decoder_specific_info(): extensionAudioObjectType")); - if (mp4ASC->objectTypeIndex == 5) + if (tmp_OTi == 5) { mp4ASC->sbr_present_flag = (uint8_t)faad_get1bit(&ld DEBUGVAR(1,11,"parse_audio_decoder_specific_info(): sbr_present_flag")); @@ -259,6 +254,10 @@ int8_t AudioSpecificConfig2(uint8_t *pBuffer, if (mp4ASC->sbr_present_flag) { uint8_t tmp; + + /* Don't set OT to SBR until checked that it is actually there */ + mp4ASC->objectTypeIndex = tmp_OTi; + tmp = (uint8_t)faad_getbits(&ld, 4 DEBUGVAR(1,12,"parse_audio_decoder_specific_info(): extensionSamplingFrequencyIndex")); diff --git a/src/libfaad/mp4.h b/src/libfaad/mp4.h index 478c9b9be..532ba3524 100644 --- a/src/libfaad/mp4.h +++ b/src/libfaad/mp4.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: mp4.h,v 1.8 2005/10/29 23:57:07 tmmm Exp $ +** $Id: mp4.h,v 1.25 2007/11/01 12:33:32 menno Exp $ **/ #ifndef __MP4_H__ diff --git a/src/libfaad/ms.c b/src/libfaad/ms.c index 93b0a2051..97c8fb198 100644 --- a/src/libfaad/ms.c +++ b/src/libfaad/ms.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ms.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: ms.c,v 1.21 2007/11/01 12:33:32 menno Exp $ **/ #include "common.h" @@ -58,7 +61,7 @@ void ms_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec, if ((ics->ms_used[g][sfb] || ics->ms_mask_present == 2) && !is_intensity(icsr, g, sfb) && !is_noise(ics, g, sfb)) { - for (i = ics->swb_offset[sfb]; i < ics->swb_offset[sfb+1]; i++) + for (i = ics->swb_offset[sfb]; i < min(ics->swb_offset[sfb+1], ics->swb_offset_max); i++) { k = (group*nshort) + i; tmp = l_spec[k] - r_spec[k]; diff --git a/src/libfaad/ms.h b/src/libfaad/ms.h index 4bc7c8175..30cfadaf6 100644 --- a/src/libfaad/ms.h +++ b/src/libfaad/ms.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ms.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: ms.h,v 1.19 2007/11/01 12:33:32 menno Exp $ **/ #ifndef __MS_H__ diff --git a/src/libfaad/output.c b/src/libfaad/output.c index 33ebed39c..a96ebd983 100644 --- a/src/libfaad/output.c +++ b/src/libfaad/output.c @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: output.c,v 1.9 2006/06/30 21:36:27 dgp85 Exp $ +** $Id: output.c,v 1.46 2007/11/01 12:33:32 menno Exp $ **/ #include "common.h" @@ -463,7 +466,7 @@ static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample } } -static void* output_to_PCM_orig(NeAACDecHandle hDecoder, +void* output_to_PCM(NeAACDecHandle hDecoder, real_t **input, void *sample_buffer, uint8_t channels, uint16_t frame_len, uint8_t format) { @@ -554,56 +557,4 @@ static void* output_to_PCM_orig(NeAACDecHandle hDecoder, return sample_buffer; } -void *output_to_PCM(NeAACDecHandle hDecoder, - real_t **input, void *sample_buffer, uint8_t channels, - uint16_t frame_len, uint8_t format) -{ - int ch, i; - int16_t *short_sample_buffer; - real_t *ch0, *ch1, *ch2, *ch3, *ch4; - - if (format != FAAD_FMT_16BIT) - return output_to_PCM_orig(hDecoder, input, sample_buffer, channels, frame_len, format); - - short_sample_buffer = (int16_t *)sample_buffer; - ch0 = input[hDecoder->internal_channel[0]]; - ch1 = input[hDecoder->internal_channel[1]]; - ch2 = input[hDecoder->internal_channel[2]]; - ch3 = input[hDecoder->internal_channel[3]]; - ch4 = input[hDecoder->internal_channel[4]]; - - if (hDecoder->downMatrix) - { - for (i = 0; i < frame_len; ++i) - { - int32_t tmp = (ch1[i] + ((ch0[i] + ch3[i]) >> 1) + ((ch0[i] + ch3[i]) >> 2) + (1 << (REAL_BITS))) >> (REAL_BITS + 1); - if ((tmp + 0x8000) & ~0xffff) - tmp = ~(tmp >> 31) - 0x8000; - short_sample_buffer[0] = tmp; - tmp = (ch2[i] + ((ch0[i] + ch4[i]) >> 1) + ((ch0[i] + ch4[i]) >> 2) + (1 << (REAL_BITS))) >> (REAL_BITS + 1); - if ((tmp + 0x8000) & ~0xffff) - tmp = ~(tmp >> 31) - 0x8000; - short_sample_buffer[1] = tmp; - short_sample_buffer += channels; - } - return sample_buffer; - } - - /* Copy output to a standard PCM buffer */ - for (i = 0; i < frame_len; ++i) - { - for (ch = 0; ch < channels; ++ch) - { - int32_t tmp = input[hDecoder->internal_channel[ch]][i]; - tmp += (1 << (REAL_BITS - 1)); - tmp >>= REAL_BITS; - if ((tmp + 0x8000) & ~0xffff) - tmp = ~(tmp >> 31) - 0x8000; - *(short_sample_buffer++) = tmp; - } - } - - return sample_buffer; -} - #endif diff --git a/src/libfaad/output.h b/src/libfaad/output.h index 1b15dae58..0451d8b73 100644 --- a/src/libfaad/output.h +++ b/src/libfaad/output.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: output.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: output.h,v 1.25 2007/11/01 12:33:32 menno Exp $ **/ #ifndef __OUTPUT_H__ diff --git a/src/libfaad/pns.c b/src/libfaad/pns.c index 5266d8eef..248fd05ef 100644 --- a/src/libfaad/pns.c +++ b/src/libfaad/pns.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: pns.c,v 1.8 2005/10/29 23:57:07 tmmm Exp $ +** $Id: pns.c,v 1.38 2007/11/01 12:33:32 menno Exp $ **/ #include "common.h" @@ -33,7 +36,8 @@ /* static function declarations */ static void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size, - uint8_t sub); + uint8_t sub, + /* RNG states */ uint32_t *__r1, uint32_t *__r2); #ifdef FIXED_POINT @@ -68,7 +72,7 @@ real_t fp_sqrt(real_t value) return root; } -static real_t pow2_table[] = +static real_t const pow2_table[] = { COEF_CONST(1.0), COEF_CONST(1.18920711500272), @@ -83,7 +87,8 @@ static real_t pow2_table[] = multiplication/accumulation per random value. */ static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t size, - uint8_t sub) + uint8_t sub, + /* RNG states */ uint32_t *__r1, uint32_t *__r2) { #ifndef FIXED_POINT uint16_t i; @@ -93,7 +98,7 @@ static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t for (i = 0; i < size; i++) { - real_t tmp = scale*(real_t)(int32_t)random_int(); + real_t tmp = scale*(real_t)(int32_t)ne_rng(__r1, __r2); spec[i] = tmp; energy += tmp*tmp; } @@ -112,7 +117,7 @@ static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t for (i = 0; i < size; i++) { /* this can be replaced by a 16 bit random generator!!!! */ - real_t tmp = (int32_t)random_int(); + real_t tmp = (int32_t)ne_rng(__r1, __r2); if (tmp < 0) tmp = -(tmp & ((1<<(REAL_BITS-1))-1)); else @@ -152,7 +157,8 @@ static INLINE void gen_rand_vector(real_t *spec, int16_t scale_factor, uint16_t void pns_decode(ic_stream *ics_left, ic_stream *ics_right, real_t *spec_left, real_t *spec_right, uint16_t frame_len, - uint8_t channel_pair, uint8_t object_type) + uint8_t channel_pair, uint8_t object_type, + /* RNG states */ uint32_t *__r1, uint32_t *__r2) { uint8_t g, sfb, b; uint16_t size, offs; @@ -202,11 +208,11 @@ void pns_decode(ic_stream *ics_left, ic_stream *ics_right, #endif offs = ics_left->swb_offset[sfb]; - size = ics_left->swb_offset[sfb+1] - offs; + size = min(ics_left->swb_offset[sfb+1], ics_left->swb_offset_max) - offs; /* Generate random vector */ gen_rand_vector(&spec_left[(group*nshort)+offs], - ics_left->scale_factors[g][sfb], size, sub); + ics_left->scale_factors[g][sfb], size, sub, __r1, __r2); } /* From the spec: @@ -233,7 +239,7 @@ void pns_decode(ic_stream *ics_left, ic_stream *ics_right, uint16_t c; offs = ics_right->swb_offset[sfb]; - size = ics_right->swb_offset[sfb+1] - offs; + size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs; for (c = 0; c < size; c++) { @@ -250,11 +256,11 @@ void pns_decode(ic_stream *ics_left, ic_stream *ics_right, #endif offs = ics_right->swb_offset[sfb]; - size = ics_right->swb_offset[sfb+1] - offs; + size = min(ics_right->swb_offset[sfb+1], ics_right->swb_offset_max) - offs; /* Generate random vector */ gen_rand_vector(&spec_right[(group*nshort)+offs], - ics_right->scale_factors[g][sfb], size, sub); + ics_right->scale_factors[g][sfb], size, sub, __r1, __r2); } } } diff --git a/src/libfaad/pns.h b/src/libfaad/pns.h index 2f246cc4f..38ced252d 100644 --- a/src/libfaad/pns.h +++ b/src/libfaad/pns.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: pns.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: pns.h,v 1.27 2007/11/01 12:33:33 menno Exp $ **/ #ifndef __PNS_H__ @@ -38,7 +41,8 @@ extern "C" { void pns_decode(ic_stream *ics_left, ic_stream *ics_right, real_t *spec_left, real_t *spec_right, uint16_t frame_len, - uint8_t channel_pair, uint8_t object_type); + uint8_t channel_pair, uint8_t object_type, + /* RNG states */ uint32_t *__r1, uint32_t *__r2); static INLINE uint8_t is_noise(ic_stream *ics, uint8_t group, uint8_t sfb) { diff --git a/src/libfaad/ps_dec.c b/src/libfaad/ps_dec.c index 3b957bfda..aebfe0a48 100644 --- a/src/libfaad/ps_dec.c +++ b/src/libfaad/ps_dec.c @@ -1,28 +1,31 @@ /* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ps_dec.c,v 1.3 2006/09/26 17:55:59 dgp85 Exp $ +** $Id: ps_dec.c,v 1.14 2007/11/01 12:33:33 menno Exp $ **/ #include "common.h" @@ -159,7 +162,7 @@ typedef struct /* static function declarations */ static void ps_data_decode(ps_info *ps); -static hyb_info *hybrid_init(void); +static hyb_info *hybrid_init(); static void channel_filter2(hyb_info *hyb, uint8_t frame_len, const real_t *filter, qmf_t *buffer, qmf_t **X_hybrid); static void INLINE DCT3_4_unscaled(real_t *y, real_t *x); @@ -175,7 +178,7 @@ static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev, int8_t min_index, int8_t max_index); static void delta_modulo_decode(uint8_t enable, int8_t *index, int8_t *index_prev, uint8_t dt_flag, uint8_t nr_par, uint8_t stride, - int8_t log2modulo); + int8_t and_modulo); static void map20indexto34(int8_t *index, uint8_t bins); #ifdef PS_LOW_POWER static void map34indexto20(int8_t *index, uint8_t bins); @@ -189,7 +192,7 @@ static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64 /* */ -static hyb_info *hybrid_init(void) +static hyb_info *hybrid_init() { uint8_t i; @@ -230,16 +233,24 @@ static void hybrid_free(hyb_info *hyb) { uint8_t i; - faad_free(hyb->work); + if (hyb->work) + faad_free(hyb->work); for (i = 0; i < 5; i++) - faad_free(hyb->buffer[i]); - faad_free(hyb->buffer); + { + if (hyb->buffer[i]) + faad_free(hyb->buffer[i]); + } + if (hyb->buffer) + faad_free(hyb->buffer); for (i = 0; i < hyb->frame_len; i++) - faad_free(hyb->temp[i]); - - faad_free(hyb->temp); + { + if (hyb->temp[i]) + faad_free(hyb->temp[i]); + } + if (hyb->temp) + faad_free(hyb->temp); } /* real filter, size 2 */ @@ -666,7 +677,7 @@ static void delta_decode(uint8_t enable, int8_t *index, int8_t *index_prev, /* in: log2 value of the modulo value to allow using AND instead of MOD */ static void delta_modulo_decode(uint8_t enable, int8_t *index, int8_t *index_prev, uint8_t dt_flag, uint8_t nr_par, uint8_t stride, - int8_t log2modulo) + int8_t and_modulo) { int8_t i; @@ -676,19 +687,19 @@ static void delta_modulo_decode(uint8_t enable, int8_t *index, int8_t *index_pre { /* delta coded in frequency direction */ index[0] = 0 + index[0]; - index[0] &= log2modulo; + index[0] &= and_modulo; for (i = 1; i < nr_par; i++) { index[i] = index[i-1] + index[i]; - index[i] &= log2modulo; + index[i] &= and_modulo; } } else { /* delta coded in time direction */ for (i = 0; i < nr_par; i++) { index[i] = index_prev[i*stride] + index[i]; - index[i] &= log2modulo; + index[i] &= and_modulo; } } } else { @@ -833,11 +844,11 @@ static void ps_data_decode(ps_info *ps) /* delta modulo decode ipd parameters */ delta_modulo_decode(ps->enable_ipdopd, ps->ipd_index[env], ipd_index_prev, - ps->ipd_dt[env], ps->nr_ipdopd_par, 1, /*log2(8)*/ 3); + ps->ipd_dt[env], ps->nr_ipdopd_par, 1, 7); /* delta modulo decode opd parameters */ delta_modulo_decode(ps->enable_ipdopd, ps->opd_index[env], opd_index_prev, - ps->opd_dt[env], ps->nr_ipdopd_par, 1, /*log2(8)*/ 3); + ps->opd_dt[env], ps->nr_ipdopd_par, 1, 7); } /* handle error case */ @@ -906,8 +917,6 @@ static void ps_data_decode(ps_info *ps) if (ps->border_position[ps->num_env] < 32 /* 30 for 960? */) { - ps->num_env++; - ps->border_position[ps->num_env] = 32 /* 30 for 960? */; for (bin = 0; bin < 34; bin++) { ps->iid_index[ps->num_env][bin] = ps->iid_index[ps->num_env-1][bin]; @@ -918,6 +927,8 @@ static void ps_data_decode(ps_info *ps) ps->ipd_index[ps->num_env][bin] = ps->ipd_index[ps->num_env-1][bin]; ps->opd_index[ps->num_env][bin] = ps->opd_index[ps->num_env-1][bin]; } + ps->num_env++; + ps->border_position[ps->num_env] = 32 /* 30 for 960? */; } for (env = 1; env < ps->num_env; env++) @@ -1410,6 +1421,26 @@ static const real_t ipdopd_sin_tab[] = { FRAC_CONST(-0.000000000000000) }; +static real_t magnitude_c(complex_t c) +{ +#ifdef FIXED_POINT +#define ps_abs(A) (((A) > 0) ? (A) : (-(A))) +#define ALPHA FRAC_CONST(0.948059448969) +#define BETA FRAC_CONST(0.392699081699) + + real_t abs_inphase = ps_abs(RE(c)); + real_t abs_quadrature = ps_abs(IM(c)); + + if (abs_inphase > abs_quadrature) { + return MUL_F(abs_inphase, ALPHA) + MUL_F(abs_quadrature, BETA); + } else { + return MUL_F(abs_quadrature, ALPHA) + MUL_F(abs_inphase, BETA); + } +#else + return sqrt(RE(c)*RE(c) + IM(c)*IM(c)); +#endif +} + static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64], qmf_t X_hybrid_left[32][32], qmf_t X_hybrid_right[32][32]) { @@ -1580,8 +1611,7 @@ static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64 if ((ps->enable_ipdopd) && (bk < nr_ipdopd_par)) { int8_t i; - real_t xxyy, ppqq; - real_t yq, xp, xq, py, tmp; + real_t xy, pq, xypq; /* ringbuffer index */ i = ps->phase_hist; @@ -1614,7 +1644,7 @@ static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64 /* ringbuffer index */ if (i == 0) - { + { i = 2; } i--; @@ -1644,53 +1674,54 @@ static void ps_mix_phase(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64 RE(phaseRight) = (float)cos(opd); IM(phaseRight) = (float)sin(opd); #else + // x = IM(tempLeft) // y = RE(tempLeft) // p = IM(tempRight) // q = RE(tempRight) - // cos(atan2(x,y)) = 1/sqrt(1 + (x*x)/(y*y)) - // sin(atan2(x,y)) = x/(y*sqrt(1 + (x*x)/(y*y))) - // cos(atan2(x,y)-atan2(p,q)) = (y*q+x*p)/(y*q * sqrt(1 + (x*x)/(y*y)) * sqrt(1 + (p*p)/(q*q))); - // sin(atan2(x,y)-atan2(p,q)) = (x*q-p*y)/(y*q * sqrt(1 + (x*x)/(y*y)) * sqrt(1 + (p*p)/(q*q))); + // cos(atan2(x,y)) = y/sqrt((x*x) + (y*y)) + // sin(atan2(x,y)) = x/sqrt((x*x) + (y*y)) + // cos(atan2(x,y)-atan2(p,q)) = (y*q + x*p) / ( sqrt((x*x) + (y*y)) * sqrt((p*p) + (q*q)) ); + // sin(atan2(x,y)-atan2(p,q)) = (x*q - y*p) / ( sqrt((x*x) + (y*y)) * sqrt((p*p) + (q*q)) ); - /* (x*x)/(y*y) (REAL > 0) */ - xxyy = DIV_R(MUL_C(IM(tempLeft),IM(tempLeft)), MUL_C(RE(tempLeft),RE(tempLeft))); - ppqq = DIV_R(MUL_C(IM(tempRight),IM(tempRight)), MUL_C(RE(tempRight),RE(tempRight))); + xy = magnitude_c(tempRight); + pq = magnitude_c(tempLeft); - /* 1 + (x*x)/(y*y) (REAL > 1) */ - xxyy += REAL_CONST(1); - ppqq += REAL_CONST(1); - - /* 1 / sqrt(1 + (x*x)/(y*y)) (FRAC <= 1) */ - xxyy = DIV_R(FRAC_CONST(1), ps_sqrt(xxyy)); - ppqq = DIV_R(FRAC_CONST(1), ps_sqrt(ppqq)); + if (xy != 0) + { + RE(phaseLeft) = DIV_R(RE(tempRight), xy); + IM(phaseLeft) = DIV_R(IM(tempRight), xy); + } else { + RE(phaseLeft) = 0; + IM(phaseLeft) = 0; + } - /* COEF */ - yq = MUL_C(RE(tempLeft), RE(tempRight)); - xp = MUL_C(IM(tempLeft), IM(tempRight)); - xq = MUL_C(IM(tempLeft), RE(tempRight)); - py = MUL_C(RE(tempLeft), IM(tempRight)); + xypq = MUL_R(xy, pq); - RE(phaseLeft) = xxyy; - IM(phaseLeft) = MUL_R(xxyy, (DIV_R(IM(tempLeft), RE(tempLeft)))); + if (xypq != 0) + { + real_t tmp1 = MUL_R(RE(tempRight), RE(tempLeft)) + MUL_R(IM(tempRight), IM(tempLeft)); + real_t tmp2 = MUL_R(IM(tempRight), RE(tempLeft)) - MUL_R(RE(tempRight), IM(tempLeft)); - tmp = DIV_C(MUL_F(xxyy, ppqq), yq); + RE(phaseRight) = DIV_R(tmp1, xypq); + IM(phaseRight) = DIV_R(tmp2, xypq); + } else { + RE(phaseRight) = 0; + IM(phaseRight) = 0; + } - /* MUL_C(FRAC,COEF) = FRAC */ - RE(phaseRight) = MUL_C(tmp, (yq+xp)); - IM(phaseRight) = MUL_C(tmp, (xq-py)); #endif - /* MUL_F(COEF, FRAC) = COEF */ - IM(h11) = MUL_F(RE(h11), IM(phaseLeft)); - IM(h12) = MUL_F(RE(h12), IM(phaseRight)); - IM(h21) = MUL_F(RE(h21), IM(phaseLeft)); - IM(h22) = MUL_F(RE(h22), IM(phaseRight)); + /* MUL_F(COEF, REAL) = COEF */ + IM(h11) = MUL_R(RE(h11), IM(phaseLeft)); + IM(h12) = MUL_R(RE(h12), IM(phaseRight)); + IM(h21) = MUL_R(RE(h21), IM(phaseLeft)); + IM(h22) = MUL_R(RE(h22), IM(phaseRight)); - RE(h11) = MUL_F(RE(h11), RE(phaseLeft)); - RE(h12) = MUL_F(RE(h12), RE(phaseRight)); - RE(h21) = MUL_F(RE(h21), RE(phaseLeft)); - RE(h22) = MUL_F(RE(h22), RE(phaseRight)); + RE(h11) = MUL_R(RE(h11), RE(phaseLeft)); + RE(h12) = MUL_R(RE(h12), RE(phaseRight)); + RE(h21) = MUL_R(RE(h21), RE(phaseLeft)); + RE(h22) = MUL_R(RE(h22), RE(phaseRight)); } /* length of the envelope n_e+1 - n_e (in time samples) */ @@ -1927,8 +1958,8 @@ ps_info *ps_init(uint8_t sr_index) /* main Parametric Stereo decoding function */ uint8_t ps_decode(ps_info *ps, qmf_t X_left[38][64], qmf_t X_right[38][64]) { - qmf_t X_hybrid_left[32][32] = {{{0}}}; - qmf_t X_hybrid_right[32][32] = {{{0}}}; + qmf_t X_hybrid_left[32][32] = {{0}}; + qmf_t X_hybrid_right[32][32] = {{0}}; /* delta decoding of the bitstream data */ ps_data_decode(ps); diff --git a/src/libfaad/ps_dec.h b/src/libfaad/ps_dec.h index 978161fff..d96561404 100644 --- a/src/libfaad/ps_dec.h +++ b/src/libfaad/ps_dec.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ps_dec.h,v 1.1 2005/10/30 00:50:19 tmmm Exp $ +** $Id: ps_dec.h,v 1.12 2007/11/01 12:33:33 menno Exp $ **/ #ifndef __PS_DEC_H__ diff --git a/src/libfaad/ps_syntax.c b/src/libfaad/ps_syntax.c index fc2f9e7f2..50253d459 100644 --- a/src/libfaad/ps_syntax.c +++ b/src/libfaad/ps_syntax.c @@ -1,6 +1,6 @@ /* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ps_syntax.c,v 1.1 2005/10/30 00:50:19 tmmm Exp $ +** $Id: ps_syntax.c,v 1.11 2007/11/01 12:33:33 menno Exp $ **/ #include "common.h" @@ -308,9 +311,9 @@ static const int8_t t_huff_opd[][2] = { { 2, 3 }, /* index 1: 2 bits: 0x */ { 4, 5 }, /* index 2: 3 bits: 00x */ { /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ - { /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */ - { /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */ - { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */ + { /*5*/ -26, /*2*/ -29 }, /* index 4: 4 bits: 000x */ + { /*6*/ -25, 6 }, /* index 5: 4 bits: 001x */ + { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0011x */ }; /* static function declarations */ @@ -380,7 +383,10 @@ uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header) /* we are here, but no header has been read yet */ if (ps->header_read == 0) + { + ps->ps_data_available = 0; return 1; + } ps->frame_class = (uint8_t)faad_get1bit(ld DEBUGVAR(1,1006,"ps_data(): frame_class")); @@ -394,7 +400,7 @@ uint16_t ps_data(ps_info *ps, bitfile *ld, uint8_t *header) for (n = 1; n < ps->num_env+1; n++) { ps->border_position[n] = (uint8_t)faad_getbits(ld, 5 - DEBUGVAR(1,1008,"ps_data(): border_position")); + DEBUGVAR(1,1008,"ps_data(): border_position")) + 1; } } diff --git a/src/libfaad/ps_tables.h b/src/libfaad/ps_tables.h index c71489617..f3370be9d 100644 --- a/src/libfaad/ps_tables.h +++ b/src/libfaad/ps_tables.h @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ps_tables.h,v 1.1 2005/10/30 00:50:19 tmmm Exp $ +** $Id: ps_tables.h,v 1.8 2007/11/01 12:33:33 menno Exp $ **/ #ifndef __PS_TABLES_H__ @@ -541,7 +544,7 @@ static const real_t sf_iid_fine[] = { }; #ifdef __cplusplus - +} #endif #endif diff --git a/src/libfaad/pulse.c b/src/libfaad/pulse.c index 9e0a705e6..3dd973abf 100644 --- a/src/libfaad/pulse.c +++ b/src/libfaad/pulse.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,12 +19,14 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: pulse.c,v 1.8 2005/10/29 23:57:07 tmmm Exp $ +** $Id: pulse.c,v 1.21 2007/11/01 12:33:34 menno Exp $ **/ - #include "common.h" #include "structs.h" @@ -37,7 +39,7 @@ uint8_t pulse_decode(ic_stream *ics, int16_t *spec_data, uint16_t framelen) uint16_t k; pulse_info *pul = &(ics->pul); - k = ics->swb_offset[pul->pulse_start_sfb]; + k = min(ics->swb_offset[pul->pulse_start_sfb], ics->swb_offset_max); for (i = 0; i <= pul->number_pulse; i++) { diff --git a/src/libfaad/pulse.h b/src/libfaad/pulse.h index a057c0d3b..f7676cd89 100644 --- a/src/libfaad/pulse.h +++ b/src/libfaad/pulse.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: pulse.h,v 1.8 2005/10/29 23:57:07 tmmm Exp $ +** $Id: pulse.h,v 1.20 2007/11/01 12:33:34 menno Exp $ **/ #ifndef __PULSE_H__ diff --git a/src/libfaad/rvlc.c b/src/libfaad/rvlc.c index bad49a0c6..73619c6d1 100644 --- a/src/libfaad/rvlc.c +++ b/src/libfaad/rvlc.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: rvlc.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: rvlc.c,v 1.21 2007/11/01 12:33:34 menno Exp $ **/ /* RVLC scalefactor decoding diff --git a/src/libfaad/rvlc.h b/src/libfaad/rvlc.h index 867468580..56f630fa4 100644 --- a/src/libfaad/rvlc.h +++ b/src/libfaad/rvlc.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: rvlc.h,v 1.6 2005/10/29 23:57:07 tmmm Exp $ +** $Id: rvlc.h,v 1.17 2007/11/01 12:33:34 menno Exp $ **/ #ifndef __RVLC_SCF_H__ diff --git a/src/libfaad/sbr_dct.c b/src/libfaad/sbr_dct.c index ba8bbaf9b..16e7128ea 100644 --- a/src/libfaad/sbr_dct.c +++ b/src/libfaad/sbr_dct.c @@ -1,30 +1,38 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_dct.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_dct.c,v 1.20 2007/11/01 12:33:34 menno Exp $ **/ + +/* Most of the DCT/DST codes here are generated using Spiral which is GPL + * For more info see: http://www.spiral.net/ + */ + #include "common.h" #ifdef SBR_DEC @@ -479,1791 +487,1791 @@ void DCT4_32(real_t *y, real_t *x) y[1] = f397 - f396; } -#ifdef SBR_LOW_POWER - -void DCT2_16_unscaled(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f31, f32; - real_t f33, f34, f37, f38, f39, f40, f41, f42, f43, f44; - real_t f45, f46, f47, f48, f49, f51, f53, f54, f57, f58; - real_t f59, f60, f61, f62, f63, f64, f65, f66, f67, f68; - real_t f69, f70, f71, f72, f73, f74, f75, f76, f77, f78; - real_t f79, f80, f81, f82, f83, f84, f85, f86, f87, f88; - real_t f89, f90, f91, f92, f95, f96, f97, f98, f101, f102; - real_t f103, f104, f107, f108, f109, f110; - - f0 = x[0] - x[15]; - f1 = x[0] + x[15]; - f2 = x[1] - x[14]; - f3 = x[1] + x[14]; - f4 = x[2] - x[13]; - f5 = x[2] + x[13]; - f6 = x[3] - x[12]; - f7 = x[3] + x[12]; - f8 = x[4] - x[11]; - f9 = x[4] + x[11]; - f10 = x[5] - x[10]; - f11 = x[5] + x[10]; - f12 = x[6] - x[9]; - f13 = x[6] + x[9]; - f14 = x[7] - x[8]; - f15 = x[7] + x[8]; - f16 = f1 - f15; - f17 = f1 + f15; - f18 = f3 - f13; - f19 = f3 + f13; - f20 = f5 - f11; - f21 = f5 + f11; - f22 = f7 - f9; - f23 = f7 + f9; - f24 = f17 - f23; - f25 = f17 + f23; - f26 = f19 - f21; - f27 = f19 + f21; - f28 = f25 - f27; - y[0] = f25 + f27; - y[8] = MUL_F(f28, FRAC_CONST(0.7071067811865476)); - f31 = f24 + f26; - f32 = MUL_C(f24, COEF_CONST(1.3065629648763766)); - f33 = MUL_F(f31, FRAC_CONST(-0.9238795325112866)); - f34 = MUL_F(f26, FRAC_CONST(-0.5411961001461967)); - y[12] = f32 + f33; - y[4] = f34 - f33; - f37 = f16 + f22; - f38 = MUL_C(f16, COEF_CONST(1.1758756024193588)); - f39 = MUL_F(f37, FRAC_CONST(-0.9807852804032304)); - f40 = MUL_F(f22, FRAC_CONST(-0.7856949583871021)); - f41 = f38 + f39; - f42 = f40 - f39; - f43 = f18 + f20; - f44 = MUL_C(f18, COEF_CONST(1.3870398453221473)); - f45 = MUL_F(f43, FRAC_CONST(-0.8314696123025455)); - f46 = MUL_F(f20, FRAC_CONST(-0.2758993792829436)); - f47 = f44 + f45; - f48 = f46 - f45; - f49 = f42 - f48; - y[2] = f42 + f48; - f51 = MUL_F(f49, FRAC_CONST(0.7071067811865476)); - y[14] = f41 - f47; - f53 = f41 + f47; - f54 = MUL_F(f53, FRAC_CONST(0.7071067811865476)); - y[10] = f51 - f54; - y[6] = f51 + f54; - f57 = f2 - f4; - f58 = f2 + f4; - f59 = f6 - f8; - f60 = f6 + f8; - f61 = f10 - f12; - f62 = f10 + f12; - f63 = MUL_F(f60, FRAC_CONST(0.7071067811865476)); - f64 = f0 - f63; - f65 = f0 + f63; - f66 = f58 + f62; - f67 = MUL_C(f58, COEF_CONST(1.3065629648763766)); - f68 = MUL_F(f66, FRAC_CONST(-0.9238795325112866)); - f69 = MUL_F(f62, FRAC_CONST(-0.5411961001461967)); - f70 = f67 + f68; - f71 = f69 - f68; - f72 = f65 - f71; - f73 = f65 + f71; - f74 = f64 - f70; - f75 = f64 + f70; - f76 = MUL_F(f59, FRAC_CONST(0.7071067811865476)); - f77 = f14 - f76; - f78 = f14 + f76; - f79 = f61 + f57; - f80 = MUL_C(f61, COEF_CONST(1.3065629648763766)); - f81 = MUL_F(f79, FRAC_CONST(-0.9238795325112866)); - f82 = MUL_F(f57, FRAC_CONST(-0.5411961001461967)); - f83 = f80 + f81; - f84 = f82 - f81; - f85 = f78 - f84; - f86 = f78 + f84; - f87 = f77 - f83; - f88 = f77 + f83; - f89 = f86 + f73; - f90 = MUL_F(f86, FRAC_CONST(-0.8971675863426361)); - f91 = MUL_F(f89, FRAC_CONST(0.9951847266721968)); - f92 = MUL_C(f73, COEF_CONST(1.0932018670017576)); - y[1] = f90 + f91; - y[15] = f92 - f91; - f95 = f75 - f88; - f96 = MUL_F(f88, FRAC_CONST(-0.6666556584777466)); - f97 = MUL_F(f95, FRAC_CONST(0.9569403357322089)); - f98 = MUL_C(f75, COEF_CONST(1.2472250129866713)); - y[3] = f97 - f96; - y[13] = f98 - f97; - f101 = f87 + f74; - f102 = MUL_F(f87, FRAC_CONST(-0.4105245275223571)); - f103 = MUL_F(f101, FRAC_CONST(0.8819212643483549)); - f104 = MUL_C(f74, COEF_CONST(1.3533180011743529)); - y[5] = f102 + f103; - y[11] = f104 - f103; - f107 = f72 - f85; - f108 = MUL_F(f85, FRAC_CONST(-0.1386171691990915)); - f109 = MUL_F(f107, FRAC_CONST(0.7730104533627370)); - f110 = MUL_C(f72, COEF_CONST(1.4074037375263826)); - y[7] = f109 - f108; - y[9] = f110 - f109; -} - -void DCT4_16(real_t *y, real_t *x) +void DST4_32(real_t *y, real_t *x) { - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; - real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; - real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; - real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; - real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; - real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; - real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; - real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; - real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; - real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; - real_t f121, f122, f123, f124, f125, f126, f127, f128, f130, f132; - real_t f134, f136, f138, f140, f142, f144, f145, f148, f149, f152; - real_t f153, f156, f157; + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9; + real_t f10, f11, f12, f13, f14, f15, f16, f17, f18, f19; + real_t f20, f21, f22, f23, f24, f25, f26, f27, f28, f29; + real_t f30, f31, f32, f33, f34, f35, f36, f37, f38, f39; + real_t f40, f41, f42, f43, f44, f45, f46, f47, f48, f49; + real_t f50, f51, f52, f53, f54, f55, f56, f57, f58, f59; + real_t f60, f61, f62, f63, f64, f65, f66, f67, f68, f69; + real_t f70, f71, f72, f73, f74, f75, f76, f77, f78, f79; + real_t f80, f81, f82, f83, f84, f85, f86, f87, f88, f89; + real_t f90, f91, f92, f93, f94, f95, f96, f97, f98, f99; + real_t f100, f101, f102, f103, f104, f105, f106, f107, f108, f109; + real_t f110, f111, f112, f113, f114, f115, f116, f117, f118, f119; + real_t f120, f121, f122, f123, f124, f125, f126, f127, f128, f129; + real_t f130, f131, f132, f133, f134, f135, f136, f137, f138, f139; + real_t f140, f141, f142, f143, f144, f145, f146, f147, f148, f149; + real_t f150, f151, f152, f153, f154, f155, f156, f157, f158, f159; + real_t f160, f161, f162, f163, f164, f165, f166, f167, f168, f169; + real_t f170, f171, f172, f173, f174, f175, f176, f177, f178, f179; + real_t f180, f181, f182, f183, f184, f185, f186, f187, f188, f189; + real_t f190, f191, f192, f193, f194, f195, f196, f197, f198, f199; + real_t f200, f201, f202, f203, f204, f205, f206, f207, f208, f209; + real_t f210, f211, f212, f213, f214, f215, f216, f217, f218, f219; + real_t f220, f221, f222, f223, f224, f225, f226, f227, f228, f229; + real_t f230, f231, f232, f233, f234, f235, f236, f237, f238, f239; + real_t f240, f241, f242, f243, f244, f245, f246, f247, f248, f249; + real_t f250, f251, f252, f253, f254, f255, f256, f257, f258, f259; + real_t f260, f261, f262, f263, f264, f265, f266, f267, f268, f269; + real_t f270, f271, f272, f273, f274, f275, f276, f277, f278, f279; + real_t f280, f281, f282, f283, f284, f285, f286, f287, f288, f289; + real_t f290, f291, f292, f293, f294, f295, f296, f297, f298, f299; + real_t f300, f301, f302, f303, f304, f305, f306, f307, f308, f309; + real_t f310, f311, f312, f313, f314, f315, f316, f317, f318, f319; + real_t f320, f321, f322, f323, f324, f325, f326, f327, f328, f329; + real_t f330, f331, f332, f333, f334, f335; - f0 = x[0] + x[15]; - f1 = MUL_C(COEF_CONST(1.0478631305325901), x[0]); - f2 = MUL_F(FRAC_CONST(-0.9987954562051724), f0); - f3 = MUL_F(FRAC_CONST(-0.9497277818777548), x[15]); - f4 = f1 + f2; - f5 = f3 - f2; - f6 = x[2] + x[13]; - f7 = MUL_C(COEF_CONST(1.2130114330978077), x[2]); - f8 = MUL_F(FRAC_CONST(-0.9700312531945440), f6); - f9 = MUL_F(FRAC_CONST(-0.7270510732912803), x[13]); - f10 = f7 + f8; - f11 = f9 - f8; - f12 = x[4] + x[11]; - f13 = MUL_C(COEF_CONST(1.3315443865537255), x[4]); - f14 = MUL_F(FRAC_CONST(-0.9039892931234433), f12); - f15 = MUL_F(FRAC_CONST(-0.4764341996931612), x[11]); - f16 = f13 + f14; - f17 = f15 - f14; - f18 = x[6] + x[9]; - f19 = MUL_C(COEF_CONST(1.3989068359730781), x[6]); - f20 = MUL_F(FRAC_CONST(-0.8032075314806453), f18); - f21 = MUL_F(FRAC_CONST(-0.2075082269882124), x[9]); - f22 = f19 + f20; - f23 = f21 - f20; - f24 = x[8] + x[7]; - f25 = MUL_C(COEF_CONST(1.4125100802019777), x[8]); - f26 = MUL_F(FRAC_CONST(-0.6715589548470187), f24); - f27 = MUL_F(FRAC_CONST(0.0693921705079402), x[7]); - f28 = f25 + f26; - f29 = f27 - f26; - f30 = x[10] + x[5]; - f31 = MUL_C(COEF_CONST(1.3718313541934939), x[10]); - f32 = MUL_F(FRAC_CONST(-0.5141027441932219), f30); - f33 = MUL_F(FRAC_CONST(0.3436258658070501), x[5]); - f34 = f31 + f32; - f35 = f33 - f32; - f36 = x[12] + x[3]; - f37 = MUL_C(COEF_CONST(1.2784339185752409), x[12]); - f38 = MUL_F(FRAC_CONST(-0.3368898533922200), f36); - f39 = MUL_F(FRAC_CONST(0.6046542117908008), x[3]); - f40 = f37 + f38; - f41 = f39 - f38; - f42 = x[14] + x[1]; - f43 = MUL_C(COEF_CONST(1.1359069844201433), x[14]); - f44 = MUL_F(FRAC_CONST(-0.1467304744553624), f42); - f45 = MUL_F(FRAC_CONST(0.8424460355094185), x[1]); - f46 = f43 + f44; - f47 = f45 - f44; - f48 = f5 - f29; - f49 = f5 + f29; - f50 = f4 - f28; - f51 = f4 + f28; - f52 = f11 - f35; - f53 = f11 + f35; - f54 = f10 - f34; - f55 = f10 + f34; - f56 = f17 - f41; - f57 = f17 + f41; - f58 = f16 - f40; - f59 = f16 + f40; - f60 = f23 - f47; - f61 = f23 + f47; - f62 = f22 - f46; - f63 = f22 + f46; - f64 = f48 + f50; - f65 = MUL_C(COEF_CONST(1.1758756024193588), f48); - f66 = MUL_F(FRAC_CONST(-0.9807852804032304), f64); - f67 = MUL_F(FRAC_CONST(-0.7856949583871021), f50); - f68 = f65 + f66; - f69 = f67 - f66; - f70 = f52 + f54; - f71 = MUL_C(COEF_CONST(1.3870398453221475), f52); - f72 = MUL_F(FRAC_CONST(-0.5555702330196022), f70); - f73 = MUL_F(FRAC_CONST(0.2758993792829431), f54); - f74 = f71 + f72; - f75 = f73 - f72; - f76 = f56 + f58; - f77 = MUL_F(FRAC_CONST(0.7856949583871022), f56); - f78 = MUL_F(FRAC_CONST(0.1950903220161283), f76); - f79 = MUL_C(COEF_CONST(1.1758756024193586), f58); - f80 = f77 + f78; - f81 = f79 - f78; - f82 = f60 + f62; - f83 = MUL_F(FRAC_CONST(-0.2758993792829430), f60); - f84 = MUL_F(FRAC_CONST(0.8314696123025452), f82); - f85 = MUL_C(COEF_CONST(1.3870398453221475), f62); - f86 = f83 + f84; - f87 = f85 - f84; - f88 = f49 - f57; - f89 = f49 + f57; - f90 = f51 - f59; - f91 = f51 + f59; - f92 = f53 - f61; - f93 = f53 + f61; - f94 = f55 - f63; - f95 = f55 + f63; - f96 = f69 - f81; - f97 = f69 + f81; - f98 = f68 - f80; - f99 = f68 + f80; - f100 = f75 - f87; - f101 = f75 + f87; - f102 = f74 - f86; - f103 = f74 + f86; - f104 = f88 + f90; - f105 = MUL_C(COEF_CONST(1.3065629648763766), f88); - f106 = MUL_F(FRAC_CONST(-0.9238795325112866), f104); - f107 = MUL_F(FRAC_CONST(-0.5411961001461967), f90); + f0 = x[0] - x[1]; + f1 = x[2] - x[1]; + f2 = x[2] - x[3]; + f3 = x[4] - x[3]; + f4 = x[4] - x[5]; + f5 = x[6] - x[5]; + f6 = x[6] - x[7]; + f7 = x[8] - x[7]; + f8 = x[8] - x[9]; + f9 = x[10] - x[9]; + f10 = x[10] - x[11]; + f11 = x[12] - x[11]; + f12 = x[12] - x[13]; + f13 = x[14] - x[13]; + f14 = x[14] - x[15]; + f15 = x[16] - x[15]; + f16 = x[16] - x[17]; + f17 = x[18] - x[17]; + f18 = x[18] - x[19]; + f19 = x[20] - x[19]; + f20 = x[20] - x[21]; + f21 = x[22] - x[21]; + f22 = x[22] - x[23]; + f23 = x[24] - x[23]; + f24 = x[24] - x[25]; + f25 = x[26] - x[25]; + f26 = x[26] - x[27]; + f27 = x[28] - x[27]; + f28 = x[28] - x[29]; + f29 = x[30] - x[29]; + f30 = x[30] - x[31]; + f31 = MUL_F(FRAC_CONST(0.7071067811865476), f15); + f32 = x[0] - f31; + f33 = x[0] + f31; + f34 = f7 + f23; + f35 = MUL_C(COEF_CONST(1.3065629648763766), f7); + f36 = MUL_F(FRAC_CONST(-0.9238795325112866), f34); + f37 = MUL_F(FRAC_CONST(-0.5411961001461967), f23); + f38 = f35 + f36; + f39 = f37 - f36; + f40 = f33 - f39; + f41 = f33 + f39; + f42 = f32 - f38; + f43 = f32 + f38; + f44 = f11 - f19; + f45 = f11 + f19; + f46 = MUL_F(FRAC_CONST(0.7071067811865476), f45); + f47 = f3 - f46; + f48 = f3 + f46; + f49 = MUL_F(FRAC_CONST(0.7071067811865476), f44); + f50 = f49 - f27; + f51 = f49 + f27; + f52 = f51 + f48; + f53 = MUL_F(FRAC_CONST(-0.7856949583871021), f51); + f54 = MUL_F(FRAC_CONST(0.9807852804032304), f52); + f55 = MUL_C(COEF_CONST(1.1758756024193588), f48); + f56 = f53 + f54; + f57 = f55 - f54; + f58 = f50 + f47; + f59 = MUL_F(FRAC_CONST(-0.2758993792829430), f50); + f60 = MUL_F(FRAC_CONST(0.8314696123025452), f58); + f61 = MUL_C(COEF_CONST(1.3870398453221475), f47); + f62 = f59 + f60; + f63 = f61 - f60; + f64 = f41 - f56; + f65 = f41 + f56; + f66 = f43 - f62; + f67 = f43 + f62; + f68 = f42 - f63; + f69 = f42 + f63; + f70 = f40 - f57; + f71 = f40 + f57; + f72 = f5 - f9; + f73 = f5 + f9; + f74 = f13 - f17; + f75 = f13 + f17; + f76 = f21 - f25; + f77 = f21 + f25; + f78 = MUL_F(FRAC_CONST(0.7071067811865476), f75); + f79 = f1 - f78; + f80 = f1 + f78; + f81 = f73 + f77; + f82 = MUL_C(COEF_CONST(1.3065629648763766), f73); + f83 = MUL_F(FRAC_CONST(-0.9238795325112866), f81); + f84 = MUL_F(FRAC_CONST(-0.5411961001461967), f77); + f85 = f82 + f83; + f86 = f84 - f83; + f87 = f80 - f86; + f88 = f80 + f86; + f89 = f79 - f85; + f90 = f79 + f85; + f91 = MUL_F(FRAC_CONST(0.7071067811865476), f74); + f92 = f29 - f91; + f93 = f29 + f91; + f94 = f76 + f72; + f95 = MUL_C(COEF_CONST(1.3065629648763766), f76); + f96 = MUL_F(FRAC_CONST(-0.9238795325112866), f94); + f97 = MUL_F(FRAC_CONST(-0.5411961001461967), f72); + f98 = f95 + f96; + f99 = f97 - f96; + f100 = f93 - f99; + f101 = f93 + f99; + f102 = f92 - f98; + f103 = f92 + f98; + f104 = f101 + f88; + f105 = MUL_F(FRAC_CONST(-0.8971675863426361), f101); + f106 = MUL_F(FRAC_CONST(0.9951847266721968), f104); + f107 = MUL_C(COEF_CONST(1.0932018670017576), f88); f108 = f105 + f106; f109 = f107 - f106; - f110 = f92 + f94; - f111 = MUL_F(FRAC_CONST(0.5411961001461969), f92); - f112 = MUL_F(FRAC_CONST(0.3826834323650898), f110); - f113 = MUL_C(COEF_CONST(1.3065629648763766), f94); - f114 = f111 + f112; + f110 = f90 - f103; + f111 = MUL_F(FRAC_CONST(-0.6666556584777466), f103); + f112 = MUL_F(FRAC_CONST(0.9569403357322089), f110); + f113 = MUL_C(COEF_CONST(1.2472250129866713), f90); + f114 = f112 - f111; f115 = f113 - f112; - f116 = f96 + f98; - f117 = MUL_C(COEF_CONST(1.3065629648763766), f96); - f118 = MUL_F(FRAC_CONST(-0.9238795325112866), f116); - f119 = MUL_F(FRAC_CONST(-0.5411961001461967), f98); + f116 = f102 + f89; + f117 = MUL_F(FRAC_CONST(-0.4105245275223571), f102); + f118 = MUL_F(FRAC_CONST(0.8819212643483549), f116); + f119 = MUL_C(COEF_CONST(1.3533180011743529), f89); f120 = f117 + f118; f121 = f119 - f118; - f122 = f100 + f102; - f123 = MUL_F(FRAC_CONST(0.5411961001461969), f100); - f124 = MUL_F(FRAC_CONST(0.3826834323650898), f122); - f125 = MUL_C(COEF_CONST(1.3065629648763766), f102); - f126 = f123 + f124; + f122 = f87 - f100; + f123 = MUL_F(FRAC_CONST(-0.1386171691990915), f100); + f124 = MUL_F(FRAC_CONST(0.7730104533627370), f122); + f125 = MUL_C(COEF_CONST(1.4074037375263826), f87); + f126 = f124 - f123; f127 = f125 - f124; - f128 = f89 - f93; - y[0] = f89 + f93; - f130 = f91 - f95; - y[15] = f91 + f95; - f132 = f109 - f115; - y[3] = f109 + f115; - f134 = f108 - f114; - y[12] = f108 + f114; - f136 = f97 - f101; - y[1] = f97 + f101; - f138 = f99 - f103; - y[14] = f99 + f103; - f140 = f121 - f127; - y[2] = f121 + f127; - f142 = f120 - f126; - y[13] = f120 + f126; - f144 = f128 - f130; - f145 = f128 + f130; - y[8] = MUL_F(FRAC_CONST(0.7071067811865474), f144); - y[7] = MUL_F(FRAC_CONST(0.7071067811865474), f145); - f148 = f132 - f134; - f149 = f132 + f134; - y[11] = MUL_F(FRAC_CONST(0.7071067811865474), f148); - y[4] = MUL_F(FRAC_CONST(0.7071067811865474), f149); - f152 = f136 - f138; - f153 = f136 + f138; - y[9] = MUL_F(FRAC_CONST(0.7071067811865474), f152); - y[6] = MUL_F(FRAC_CONST(0.7071067811865474), f153); - f156 = f140 - f142; - f157 = f140 + f142; - y[10] = MUL_F(FRAC_CONST(0.7071067811865474), f156); - y[5] = MUL_F(FRAC_CONST(0.7071067811865474), f157); -} - -void DCT3_32_unscaled(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; - real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; - real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; - real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; - real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; - real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; - real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; - real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; - real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; - real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; - real_t f121, f122, f123, f124, f125, f126, f127, f128, f129, f130; - real_t f131, f132, f133, f134, f135, f136, f137, f138, f139, f140; - real_t f141, f142, f143, f144, f145, f146, f147, f148, f149, f150; - real_t f151, f152, f153, f154, f155, f156, f157, f158, f159, f160; - real_t f161, f162, f163, f164, f165, f166, f167, f168, f169, f170; - real_t f171, f172, f173, f174, f175, f176, f177, f178, f179, f180; - real_t f181, f182, f183, f184, f185, f186, f187, f188, f189, f190; - real_t f191, f192, f193, f194, f195, f196, f197, f198, f199, f200; - real_t f201, f202, f203, f204, f205, f206, f207, f208, f209, f210; - real_t f211, f212, f213, f214, f215, f216, f217, f218, f219, f220; - real_t f221, f222, f223, f224, f225, f226, f227, f228, f229, f230; - real_t f231, f232, f233, f234, f235, f236, f237, f238, f239, f240; - real_t f241, f242, f243, f244, f245, f246, f247, f248, f249, f250; - real_t f251, f252, f253, f254, f255, f256, f257, f258, f259, f260; - real_t f261, f262, f263, f264, f265, f266, f267, f268, f269, f270; - real_t f271, f272; - - f0 = MUL_F(x[16], FRAC_CONST(0.7071067811865476)); - f1 = x[0] - f0; - f2 = x[0] + f0; - f3 = x[8] + x[24]; - f4 = MUL_C(x[8], COEF_CONST(1.3065629648763766)); - f5 = MUL_F(f3, FRAC_CONST((-0.9238795325112866))); - f6 = MUL_F(x[24], FRAC_CONST((-0.5411961001461967))); - f7 = f4 + f5; - f8 = f6 - f5; - f9 = f2 - f8; - f10 = f2 + f8; - f11 = f1 - f7; - f12 = f1 + f7; - f13 = x[4] + x[28]; - f14 = MUL_C(x[4], COEF_CONST(1.1758756024193588)); - f15 = MUL_F(f13, FRAC_CONST((-0.9807852804032304))); - f16 = MUL_F(x[28], FRAC_CONST((-0.7856949583871021))); - f17 = f14 + f15; - f18 = f16 - f15; - f19 = x[12] + x[20]; - f20 = MUL_C(x[12], COEF_CONST(1.3870398453221473)); - f21 = MUL_F(f19, FRAC_CONST((-0.8314696123025455))); - f22 = MUL_F(x[20], FRAC_CONST((-0.2758993792829436))); - f23 = f20 + f21; - f24 = f22 - f21; - f25 = f18 - f24; - f26 = f18 + f24; - f27 = MUL_F(f25, FRAC_CONST(0.7071067811865476)); - f28 = f17 - f23; - f29 = f17 + f23; - f30 = MUL_F(f29, FRAC_CONST(0.7071067811865476)); - f31 = f27 - f30; - f32 = f27 + f30; - f33 = f10 - f26; - f34 = f10 + f26; - f35 = f12 - f32; - f36 = f12 + f32; - f37 = f11 - f31; - f38 = f11 + f31; - f39 = f9 - f28; - f40 = f9 + f28; - f41 = x[2] + x[30]; - f42 = MUL_C(x[2], COEF_CONST(1.0932018670017569)); - f43 = MUL_F(f41, FRAC_CONST((-0.9951847266721969))); - f44 = MUL_F(x[30], FRAC_CONST((-0.8971675863426368))); - f45 = f42 + f43; - f46 = f44 - f43; - f47 = x[6] + x[26]; - f48 = MUL_C(x[6], COEF_CONST(1.2472250129866711)); - f49 = MUL_F(f47, FRAC_CONST((-0.9569403357322089))); - f50 = MUL_F(x[26], FRAC_CONST((-0.6666556584777469))); - f51 = f48 + f49; - f52 = f50 - f49; - f53 = x[10] + x[22]; - f54 = MUL_C(x[10], COEF_CONST(1.3533180011743526)); - f55 = MUL_F(f53, FRAC_CONST((-0.8819212643483551))); - f56 = MUL_F(x[22], FRAC_CONST((-0.4105245275223575))); - f57 = f54 + f55; - f58 = f56 - f55; - f59 = x[14] + x[18]; - f60 = MUL_C(x[14], COEF_CONST(1.4074037375263826)); - f61 = MUL_F(f59, FRAC_CONST((-0.7730104533627369))); - f62 = MUL_F(x[18], FRAC_CONST((-0.1386171691990913))); - f63 = f60 + f61; - f64 = f62 - f61; - f65 = f46 - f64; - f66 = f46 + f64; - f67 = f52 - f58; - f68 = f52 + f58; - f69 = f66 - f68; - f70 = f66 + f68; - f71 = MUL_F(f69, FRAC_CONST(0.7071067811865476)); - f72 = f65 + f67; - f73 = MUL_C(f65, COEF_CONST(1.3065629648763766)); - f74 = MUL_F(f72, FRAC_CONST((-0.9238795325112866))); - f75 = MUL_F(f67, FRAC_CONST((-0.5411961001461967))); - f76 = f73 + f74; - f77 = f75 - f74; - f78 = f45 - f63; - f79 = f45 + f63; - f80 = f51 - f57; - f81 = f51 + f57; - f82 = f79 + f81; - f83 = MUL_C(f79, COEF_CONST(1.3065629648763770)); - f84 = MUL_F(f82, FRAC_CONST((-0.3826834323650904))); - f85 = MUL_F(f81, FRAC_CONST(0.5411961001461961)); - f86 = f83 + f84; - f87 = f85 - f84; - f88 = f78 - f80; - f89 = f78 + f80; - f90 = MUL_F(f89, FRAC_CONST(0.7071067811865476)); - f91 = f77 - f87; - f92 = f77 + f87; - f93 = f71 - f90; - f94 = f71 + f90; - f95 = f76 - f86; - f96 = f76 + f86; - f97 = f34 - f70; - f98 = f34 + f70; - f99 = f36 - f92; - f100 = f36 + f92; - f101 = f38 - f91; - f102 = f38 + f91; - f103 = f40 - f94; - f104 = f40 + f94; - f105 = f39 - f93; - f106 = f39 + f93; - f107 = f37 - f96; - f108 = f37 + f96; - f109 = f35 - f95; - f110 = f35 + f95; - f111 = f33 - f88; - f112 = f33 + f88; - f113 = x[1] + x[31]; - f114 = MUL_C(x[1], COEF_CONST(1.0478631305325901)); - f115 = MUL_F(f113, FRAC_CONST((-0.9987954562051724))); - f116 = MUL_F(x[31], FRAC_CONST((-0.9497277818777548))); - f117 = f114 + f115; - f118 = f116 - f115; - f119 = x[5] + x[27]; - f120 = MUL_C(x[5], COEF_CONST(1.2130114330978077)); - f121 = MUL_F(f119, FRAC_CONST((-0.9700312531945440))); - f122 = MUL_F(x[27], FRAC_CONST((-0.7270510732912803))); - f123 = f120 + f121; - f124 = f122 - f121; - f125 = x[9] + x[23]; - f126 = MUL_C(x[9], COEF_CONST(1.3315443865537255)); - f127 = MUL_F(f125, FRAC_CONST((-0.9039892931234433))); - f128 = MUL_F(x[23], FRAC_CONST((-0.4764341996931612))); - f129 = f126 + f127; - f130 = f128 - f127; - f131 = x[13] + x[19]; - f132 = MUL_C(x[13], COEF_CONST(1.3989068359730781)); - f133 = MUL_F(f131, FRAC_CONST((-0.8032075314806453))); - f134 = MUL_F(x[19], FRAC_CONST((-0.2075082269882124))); - f135 = f132 + f133; - f136 = f134 - f133; - f137 = x[17] + x[15]; - f138 = MUL_C(x[17], COEF_CONST(1.4125100802019777)); - f139 = MUL_F(f137, FRAC_CONST((-0.6715589548470187))); - f140 = MUL_F(x[15], FRAC_CONST(0.0693921705079402)); - f141 = f138 + f139; - f142 = f140 - f139; - f143 = x[21] + x[11]; - f144 = MUL_C(x[21], COEF_CONST(1.3718313541934939)); - f145 = MUL_F(f143, FRAC_CONST((-0.5141027441932219))); - f146 = MUL_F(x[11], FRAC_CONST(0.3436258658070501)); - f147 = f144 + f145; - f148 = f146 - f145; - f149 = x[25] + x[7]; - f150 = MUL_C(x[25], COEF_CONST(1.2784339185752409)); - f151 = MUL_F(f149, FRAC_CONST((-0.3368898533922200))); - f152 = MUL_F(x[7], FRAC_CONST(0.6046542117908008)); - f153 = f150 + f151; - f154 = f152 - f151; - f155 = x[29] + x[3]; - f156 = MUL_C(x[29], COEF_CONST(1.1359069844201433)); - f157 = MUL_F(f155, FRAC_CONST((-0.1467304744553624))); - f158 = MUL_F(x[3], FRAC_CONST(0.8424460355094185)); - f159 = f156 + f157; - f160 = f158 - f157; - f161 = f118 - f142; - f162 = f118 + f142; - f163 = f117 - f141; - f164 = f117 + f141; - f165 = f124 - f148; - f166 = f124 + f148; - f167 = f123 - f147; - f168 = f123 + f147; - f169 = f130 - f154; - f170 = f130 + f154; - f171 = f129 - f153; - f172 = f129 + f153; - f173 = f136 - f160; - f174 = f136 + f160; - f175 = f135 - f159; - f176 = f135 + f159; - f177 = f161 + f163; - f178 = MUL_C(f161, COEF_CONST(1.1758756024193588)); - f179 = MUL_F(f177, FRAC_CONST((-0.9807852804032304))); - f180 = MUL_F(f163, FRAC_CONST((-0.7856949583871021))); - f181 = f178 + f179; - f182 = f180 - f179; - f183 = f165 + f167; - f184 = MUL_C(f165, COEF_CONST(1.3870398453221475)); - f185 = MUL_F(f183, FRAC_CONST((-0.5555702330196022))); - f186 = MUL_F(f167, FRAC_CONST(0.2758993792829431)); - f187 = f184 + f185; - f188 = f186 - f185; - f189 = f169 + f171; - f190 = MUL_F(f169, FRAC_CONST(0.7856949583871022)); - f191 = MUL_F(f189, FRAC_CONST(0.1950903220161283)); - f192 = MUL_C(f171, COEF_CONST(1.1758756024193586)); - f193 = f190 + f191; - f194 = f192 - f191; - f195 = f173 + f175; - f196 = MUL_F(f173, FRAC_CONST((-0.2758993792829430))); - f197 = MUL_F(f195, FRAC_CONST(0.8314696123025452)); - f198 = MUL_C(f175, COEF_CONST(1.3870398453221475)); - f199 = f196 + f197; - f200 = f198 - f197; - f201 = f162 - f170; - f202 = f162 + f170; - f203 = f164 - f172; - f204 = f164 + f172; - f205 = f166 - f174; - f206 = f166 + f174; - f207 = f168 - f176; - f208 = f168 + f176; - f209 = f182 - f194; - f210 = f182 + f194; - f211 = f181 - f193; - f212 = f181 + f193; - f213 = f188 - f200; - f214 = f188 + f200; - f215 = f187 - f199; - f216 = f187 + f199; - f217 = f201 + f203; - f218 = MUL_C(f201, COEF_CONST(1.3065629648763766)); - f219 = MUL_F(f217, FRAC_CONST((-0.9238795325112866))); - f220 = MUL_F(f203, FRAC_CONST((-0.5411961001461967))); - f221 = f218 + f219; - f222 = f220 - f219; - f223 = f205 + f207; - f224 = MUL_F(f205, FRAC_CONST(0.5411961001461969)); - f225 = MUL_F(f223, FRAC_CONST(0.3826834323650898)); - f226 = MUL_C(f207, COEF_CONST(1.3065629648763766)); - f227 = f224 + f225; - f228 = f226 - f225; - f229 = f209 + f211; - f230 = MUL_C(f209, COEF_CONST(1.3065629648763766)); - f231 = MUL_F(f229, FRAC_CONST((-0.9238795325112866))); - f232 = MUL_F(f211, FRAC_CONST((-0.5411961001461967))); - f233 = f230 + f231; - f234 = f232 - f231; - f235 = f213 + f215; - f236 = MUL_F(f213, FRAC_CONST(0.5411961001461969)); - f237 = MUL_F(f235, FRAC_CONST(0.3826834323650898)); - f238 = MUL_C(f215, COEF_CONST(1.3065629648763766)); - f239 = f236 + f237; - f240 = f238 - f237; - f241 = f202 - f206; - f242 = f202 + f206; - f243 = f204 - f208; - f244 = f204 + f208; - f245 = f222 - f228; - f246 = f222 + f228; - f247 = f221 - f227; - f248 = f221 + f227; - f249 = f210 - f214; - f250 = f210 + f214; - f251 = f212 - f216; - f252 = f212 + f216; - f253 = f234 - f240; - f254 = f234 + f240; - f255 = f233 - f239; - f256 = f233 + f239; - f257 = f241 - f243; - f258 = f241 + f243; - f259 = MUL_F(f257, FRAC_CONST(0.7071067811865474)); - f260 = MUL_F(f258, FRAC_CONST(0.7071067811865474)); - f261 = f245 - f247; - f262 = f245 + f247; - f263 = MUL_F(f261, FRAC_CONST(0.7071067811865474)); - f264 = MUL_F(f262, FRAC_CONST(0.7071067811865474)); - f265 = f249 - f251; - f266 = f249 + f251; - f267 = MUL_F(f265, FRAC_CONST(0.7071067811865474)); - f268 = MUL_F(f266, FRAC_CONST(0.7071067811865474)); - f269 = f253 - f255; - f270 = f253 + f255; - f271 = MUL_F(f269, FRAC_CONST(0.7071067811865474)); - f272 = MUL_F(f270, FRAC_CONST(0.7071067811865474)); - y[31] = f98 - f242; - y[0] = f98 + f242; - y[30] = f100 - f250; - y[1] = f100 + f250; - y[29] = f102 - f254; - y[2] = f102 + f254; - y[28] = f104 - f246; - y[3] = f104 + f246; - y[27] = f106 - f264; - y[4] = f106 + f264; - y[26] = f108 - f272; - y[5] = f108 + f272; - y[25] = f110 - f268; - y[6] = f110 + f268; - y[24] = f112 - f260; - y[7] = f112 + f260; - y[23] = f111 - f259; - y[8] = f111 + f259; - y[22] = f109 - f267; - y[9] = f109 + f267; - y[21] = f107 - f271; - y[10] = f107 + f271; - y[20] = f105 - f263; - y[11] = f105 + f263; - y[19] = f103 - f248; - y[12] = f103 + f248; - y[18] = f101 - f256; - y[13] = f101 + f256; - y[17] = f99 - f252; - y[14] = f99 + f252; - y[16] = f97 - f244; - y[15] = f97 + f244; -} - -void DCT2_32_unscaled(real_t *y, real_t *x) -{ - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; - real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; - real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; - real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; - real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; - real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; - real_t f63, f64, f65, f66, f69, f70, f71, f72, f73, f74; - real_t f75, f76, f77, f78, f79, f80, f81, f83, f85, f86; - real_t f89, f90, f91, f92, f93, f94, f95, f96, f97, f98; - real_t f99, f100, f101, f102, f103, f104, f105, f106, f107, f108; - real_t f109, f110, f111, f112, f113, f114, f115, f116, f117, f118; - real_t f119, f120, f121, f122, f123, f124, f127, f128, f129, f130; - real_t f133, f134, f135, f136, f139, f140, f141, f142, f145, f146; - real_t f147, f148, f149, f150, f151, f152, f153, f154, f155, f156; - real_t f157, f158, f159, f160, f161, f162, f163, f164, f165, f166; - real_t f167, f168, f169, f170, f171, f172, f173, f174, f175, f176; - real_t f177, f178, f179, f180, f181, f182, f183, f184, f185, f186; - real_t f187, f188, f189, f190, f191, f192, f193, f194, f195, f196; - real_t f197, f198, f199, f200, f201, f202, f203, f204, f205, f206; - real_t f207, f208, f209, f210, f211, f212, f213, f214, f215, f216; - real_t f217, f218, f219, f220, f221, f222, f223, f224, f225, f226; - real_t f227, f228, f229, f230, f231, f232, f233, f234, f235, f236; - real_t f237, f238, f239, f240, f241, f242, f243, f244, f247, f248; - real_t f249, f250, f253, f254, f255, f256, f259, f260, f261, f262; - real_t f265, f266, f267, f268, f271, f272, f273, f274, f277, f278; - real_t f279, f280, f283, f284, f285, f286; - - f0 = x[0] - x[31]; - f1 = x[0] + x[31]; - f2 = x[1] - x[30]; - f3 = x[1] + x[30]; - f4 = x[2] - x[29]; - f5 = x[2] + x[29]; - f6 = x[3] - x[28]; - f7 = x[3] + x[28]; - f8 = x[4] - x[27]; - f9 = x[4] + x[27]; - f10 = x[5] - x[26]; - f11 = x[5] + x[26]; - f12 = x[6] - x[25]; - f13 = x[6] + x[25]; - f14 = x[7] - x[24]; - f15 = x[7] + x[24]; - f16 = x[8] - x[23]; - f17 = x[8] + x[23]; - f18 = x[9] - x[22]; - f19 = x[9] + x[22]; - f20 = x[10] - x[21]; - f21 = x[10] + x[21]; - f22 = x[11] - x[20]; - f23 = x[11] + x[20]; - f24 = x[12] - x[19]; - f25 = x[12] + x[19]; - f26 = x[13] - x[18]; - f27 = x[13] + x[18]; - f28 = x[14] - x[17]; - f29 = x[14] + x[17]; - f30 = x[15] - x[16]; - f31 = x[15] + x[16]; - f32 = f1 - f31; - f33 = f1 + f31; - f34 = f3 - f29; - f35 = f3 + f29; - f36 = f5 - f27; - f37 = f5 + f27; - f38 = f7 - f25; - f39 = f7 + f25; - f40 = f9 - f23; - f41 = f9 + f23; - f42 = f11 - f21; - f43 = f11 + f21; - f44 = f13 - f19; - f45 = f13 + f19; - f46 = f15 - f17; - f47 = f15 + f17; - f48 = f33 - f47; - f49 = f33 + f47; - f50 = f35 - f45; - f51 = f35 + f45; - f52 = f37 - f43; - f53 = f37 + f43; - f54 = f39 - f41; - f55 = f39 + f41; - f56 = f49 - f55; - f57 = f49 + f55; - f58 = f51 - f53; - f59 = f51 + f53; - f60 = f57 - f59; - y[0] = f57 + f59; - y[16] = MUL_F(FRAC_CONST(0.7071067811865476), f60); - f63 = f56 + f58; - f64 = MUL_C(COEF_CONST(1.3065629648763766), f56); - f65 = MUL_F(FRAC_CONST(-0.9238795325112866), f63); - f66 = MUL_F(FRAC_CONST(-0.5411961001461967), f58); - y[24] = f64 + f65; - y[8] = f66 - f65; - f69 = f48 + f54; - f70 = MUL_C(COEF_CONST(1.1758756024193588), f48); - f71 = MUL_F(FRAC_CONST(-0.9807852804032304), f69); - f72 = MUL_F(FRAC_CONST(-0.7856949583871021), f54); - f73 = f70 + f71; - f74 = f72 - f71; - f75 = f50 + f52; - f76 = MUL_C(COEF_CONST(1.3870398453221473), f50); - f77 = MUL_F(FRAC_CONST(-0.8314696123025455), f75); - f78 = MUL_F(FRAC_CONST(-0.2758993792829436), f52); - f79 = f76 + f77; - f80 = f78 - f77; - f81 = f74 - f80; - y[4] = f74 + f80; - f83 = MUL_F(FRAC_CONST(0.7071067811865476), f81); - y[28] = f73 - f79; - f85 = f73 + f79; - f86 = MUL_F(FRAC_CONST(0.7071067811865476), f85); - y[20] = f83 - f86; - y[12] = f83 + f86; - f89 = f34 - f36; - f90 = f34 + f36; - f91 = f38 - f40; - f92 = f38 + f40; - f93 = f42 - f44; - f94 = f42 + f44; - f95 = MUL_F(FRAC_CONST(0.7071067811865476), f92); - f96 = f32 - f95; - f97 = f32 + f95; - f98 = f90 + f94; - f99 = MUL_C(COEF_CONST(1.3065629648763766), f90); - f100 = MUL_F(FRAC_CONST(-0.9238795325112866), f98); - f101 = MUL_F(FRAC_CONST(-0.5411961001461967), f94); - f102 = f99 + f100; - f103 = f101 - f100; - f104 = f97 - f103; - f105 = f97 + f103; - f106 = f96 - f102; - f107 = f96 + f102; - f108 = MUL_F(FRAC_CONST(0.7071067811865476), f91); - f109 = f46 - f108; - f110 = f46 + f108; - f111 = f93 + f89; - f112 = MUL_C(COEF_CONST(1.3065629648763766), f93); - f113 = MUL_F(FRAC_CONST(-0.9238795325112866), f111); - f114 = MUL_F(FRAC_CONST(-0.5411961001461967), f89); - f115 = f112 + f113; - f116 = f114 - f113; - f117 = f110 - f116; - f118 = f110 + f116; - f119 = f109 - f115; - f120 = f109 + f115; - f121 = f118 + f105; - f122 = MUL_F(FRAC_CONST(-0.8971675863426361), f118); - f123 = MUL_F(FRAC_CONST(0.9951847266721968), f121); - f124 = MUL_C(COEF_CONST(1.0932018670017576), f105); - y[2] = f122 + f123; - y[30] = f124 - f123; - f127 = f107 - f120; - f128 = MUL_F(FRAC_CONST(-0.6666556584777466), f120); - f129 = MUL_F(FRAC_CONST(0.9569403357322089), f127); - f130 = MUL_C(COEF_CONST(1.2472250129866713), f107); - y[6] = f129 - f128; - y[26] = f130 - f129; - f133 = f119 + f106; - f134 = MUL_F(FRAC_CONST(-0.4105245275223571), f119); - f135 = MUL_F(FRAC_CONST(0.8819212643483549), f133); - f136 = MUL_C(COEF_CONST(1.3533180011743529), f106); - y[10] = f134 + f135; - y[22] = f136 - f135; - f139 = f104 - f117; - f140 = MUL_F(FRAC_CONST(-0.1386171691990915), f117); - f141 = MUL_F(FRAC_CONST(0.7730104533627370), f139); - f142 = MUL_C(COEF_CONST(1.4074037375263826), f104); - y[14] = f141 - f140; - y[18] = f142 - f141; - f145 = f2 - f4; - f146 = f2 + f4; - f147 = f6 - f8; - f148 = f6 + f8; - f149 = f10 - f12; - f150 = f10 + f12; - f151 = f14 - f16; - f152 = f14 + f16; - f153 = f18 - f20; - f154 = f18 + f20; - f155 = f22 - f24; - f156 = f22 + f24; - f157 = f26 - f28; - f158 = f26 + f28; - f159 = MUL_F(FRAC_CONST(0.7071067811865476), f152); - f160 = f0 - f159; - f161 = f0 + f159; - f162 = f148 + f156; - f163 = MUL_C(COEF_CONST(1.3065629648763766), f148); - f164 = MUL_F(FRAC_CONST(-0.9238795325112866), f162); - f165 = MUL_F(FRAC_CONST(-0.5411961001461967), f156); - f166 = f163 + f164; - f167 = f165 - f164; - f168 = f161 - f167; - f169 = f161 + f167; - f170 = f160 - f166; - f171 = f160 + f166; - f172 = f146 + f158; - f173 = MUL_C(COEF_CONST(1.1758756024193588), f146); - f174 = MUL_F(FRAC_CONST(-0.9807852804032304), f172); - f175 = MUL_F(FRAC_CONST(-0.7856949583871021), f158); - f176 = f173 + f174; - f177 = f175 - f174; - f178 = f150 + f154; - f179 = MUL_C(COEF_CONST(1.3870398453221473), f150); - f180 = MUL_F(FRAC_CONST(-0.8314696123025455), f178); - f181 = MUL_F(FRAC_CONST(-0.2758993792829436), f154); - f182 = f179 + f180; - f183 = f181 - f180; - f184 = f177 - f183; - f185 = f177 + f183; - f186 = MUL_F(FRAC_CONST(0.7071067811865476), f184); - f187 = f176 - f182; - f188 = f176 + f182; - f189 = MUL_F(FRAC_CONST(0.7071067811865476), f188); - f190 = f186 - f189; - f191 = f186 + f189; - f192 = f169 - f185; - f193 = f169 + f185; - f194 = f171 - f191; - f195 = f171 + f191; - f196 = f170 - f190; - f197 = f170 + f190; - f198 = f168 - f187; - f199 = f168 + f187; - f200 = MUL_F(FRAC_CONST(0.7071067811865476), f151); - f201 = f30 - f200; - f202 = f30 + f200; - f203 = f155 + f147; - f204 = MUL_C(COEF_CONST(1.3065629648763766), f155); - f205 = MUL_F(FRAC_CONST(-0.9238795325112866), f203); - f206 = MUL_F(FRAC_CONST(-0.5411961001461967), f147); - f207 = f204 + f205; - f208 = f206 - f205; - f209 = f202 - f208; - f210 = f202 + f208; - f211 = f201 - f207; - f212 = f201 + f207; - f213 = f157 + f145; - f214 = MUL_C(COEF_CONST(1.1758756024193588), f157); - f215 = MUL_F(FRAC_CONST(-0.9807852804032304), f213); - f216 = MUL_F(FRAC_CONST(-0.7856949583871021), f145); - f217 = f214 + f215; - f218 = f216 - f215; - f219 = f153 + f149; - f220 = MUL_C(COEF_CONST(1.3870398453221473), f153); - f221 = MUL_F(FRAC_CONST(-0.8314696123025455), f219); - f222 = MUL_F(FRAC_CONST(-0.2758993792829436), f149); - f223 = f220 + f221; - f224 = f222 - f221; - f225 = f218 - f224; - f226 = f218 + f224; - f227 = MUL_F(FRAC_CONST(0.7071067811865476), f225); - f228 = f217 - f223; - f229 = f217 + f223; - f230 = MUL_F(FRAC_CONST(0.7071067811865476), f229); - f231 = f227 - f230; - f232 = f227 + f230; - f233 = f210 - f226; - f234 = f210 + f226; - f235 = f212 - f232; - f236 = f212 + f232; - f237 = f211 - f231; - f238 = f211 + f231; - f239 = f209 - f228; - f240 = f209 + f228; - f241 = f234 + f193; - f242 = MUL_F(FRAC_CONST(-0.9497277818777543), f234); - f243 = MUL_F(FRAC_CONST(0.9987954562051724), f241); - f244 = MUL_C(COEF_CONST(1.0478631305325905), f193); - y[1] = f242 + f243; - y[31] = f244 - f243; - f247 = f195 - f236; - f248 = MUL_F(FRAC_CONST(-0.8424460355094192), f236); - f249 = MUL_F(FRAC_CONST(0.9891765099647810), f247); - f250 = MUL_C(COEF_CONST(1.1359069844201428), f195); - y[3] = f249 - f248; - y[29] = f250 - f249; - f253 = f238 + f197; - f254 = MUL_F(FRAC_CONST(-0.7270510732912801), f238); - f255 = MUL_F(FRAC_CONST(0.9700312531945440), f253); - f256 = MUL_C(COEF_CONST(1.2130114330978079), f197); - y[5] = f254 + f255; - y[27] = f256 - f255; - f259 = f199 - f240; - f260 = MUL_F(FRAC_CONST(-0.6046542117908007), f240); - f261 = MUL_F(FRAC_CONST(0.9415440651830208), f259); - f262 = MUL_C(COEF_CONST(1.2784339185752409), f199); - y[7] = f261 - f260; - y[25] = f262 - f261; - f265 = f239 + f198; - f266 = MUL_F(FRAC_CONST(-0.4764341996931611), f239); - f267 = MUL_F(FRAC_CONST(0.9039892931234433), f265); - f268 = MUL_C(COEF_CONST(1.3315443865537255), f198); - y[9] = f266 + f267; - y[23] = f268 - f267; - f271 = f196 - f237; - f272 = MUL_F(FRAC_CONST(-0.3436258658070505), f237); - f273 = MUL_F(FRAC_CONST(0.8577286100002721), f271); - f274 = MUL_C(COEF_CONST(1.3718313541934939), f196); - y[11] = f273 - f272; - y[21] = f274 - f273; - f277 = f235 + f194; - f278 = MUL_F(FRAC_CONST(-0.2075082269882114), f235); - f279 = MUL_F(FRAC_CONST(0.8032075314806448), f277); - f280 = MUL_C(COEF_CONST(1.3989068359730783), f194); - y[13] = f278 + f279; - y[19] = f280 - f279; - f283 = f192 - f233; - f284 = MUL_F(FRAC_CONST(-0.0693921705079408), f233); - f285 = MUL_F(FRAC_CONST(0.7409511253549591), f283); - f286 = MUL_C(COEF_CONST(1.4125100802019774), f192); - y[15] = f285 - f284; - y[17] = f286 - f285; -} - -#else - - -#define n 32 -#define log2n 5 - -// w_array_real[i] = cos(2*M_PI*i/32) -static const real_t w_array_real[] = { - FRAC_CONST(1.000000000000000), FRAC_CONST(0.980785279337272), - FRAC_CONST(0.923879528329380), FRAC_CONST(0.831469603195765), - FRAC_CONST(0.707106765732237), FRAC_CONST(0.555570210304169), - FRAC_CONST(0.382683402077046), FRAC_CONST(0.195090284503576), - FRAC_CONST(0.000000000000000), FRAC_CONST(-0.195090370246552), - FRAC_CONST(-0.382683482845162), FRAC_CONST(-0.555570282993553), - FRAC_CONST(-0.707106827549476), FRAC_CONST(-0.831469651765257), - FRAC_CONST(-0.923879561784627), FRAC_CONST(-0.980785296392607) -}; - -// w_array_imag[i] = sin(-2*M_PI*i/32) -static const real_t w_array_imag[] = { - FRAC_CONST(0.000000000000000), FRAC_CONST(-0.195090327375064), - FRAC_CONST(-0.382683442461104), FRAC_CONST(-0.555570246648862), - FRAC_CONST(-0.707106796640858), FRAC_CONST(-0.831469627480512), - FRAC_CONST(-0.923879545057005), FRAC_CONST(-0.980785287864940), - FRAC_CONST(-1.000000000000000), FRAC_CONST(-0.980785270809601), - FRAC_CONST(-0.923879511601754), FRAC_CONST(-0.831469578911016), - FRAC_CONST(-0.707106734823616), FRAC_CONST(-0.555570173959476), - FRAC_CONST(-0.382683361692986), FRAC_CONST(-0.195090241632088) -}; - -// FFT decimation in frequency -// 4*16*2+16=128+16=144 multiplications -// 6*16*2+10*8+4*16*2=192+80+128=400 additions -static void fft_dif(real_t * Real, real_t * Imag) -{ - real_t w_real, w_imag; // For faster access - real_t point1_real, point1_imag, point2_real, point2_imag; // For faster access - uint32_t j, i, i2, w_index; // Counters - - // First 2 stages of 32 point FFT decimation in frequency - // 4*16*2=64*2=128 multiplications - // 6*16*2=96*2=192 additions - // Stage 1 of 32 point FFT decimation in frequency - for (i = 0; i < 16; i++) - { - point1_real = Real[i]; - point1_imag = Imag[i]; - i2 = i+16; - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - w_real = w_array_real[i]; - w_imag = w_array_imag[i]; - - // temp1 = x[i] - x[i2] - point1_real -= point2_real; - point1_imag -= point2_imag; - - // x[i1] = x[i] + x[i2] - Real[i] += point2_real; - Imag[i] += point2_imag; - - // x[i2] = (x[i] - x[i2]) * w - Real[i2] = (MUL_F(point1_real,w_real) - MUL_F(point1_imag,w_imag)); - Imag[i2] = (MUL_F(point1_real,w_imag) + MUL_F(point1_imag,w_real)); - } - // Stage 2 of 32 point FFT decimation in frequency - for (j = 0, w_index = 0; j < 8; j++, w_index += 2) - { - w_real = w_array_real[w_index]; - w_imag = w_array_imag[w_index]; - - i = j; - point1_real = Real[i]; - point1_imag = Imag[i]; - i2 = i+8; - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // temp1 = x[i] - x[i2] - point1_real -= point2_real; - point1_imag -= point2_imag; - - // x[i1] = x[i] + x[i2] - Real[i] += point2_real; - Imag[i] += point2_imag; - - // x[i2] = (x[i] - x[i2]) * w - Real[i2] = (MUL_F(point1_real,w_real) - MUL_F(point1_imag,w_imag)); - Imag[i2] = (MUL_F(point1_real,w_imag) + MUL_F(point1_imag,w_real)); - - i = j+16; - point1_real = Real[i]; - point1_imag = Imag[i]; - i2 = i+8; - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // temp1 = x[i] - x[i2] - point1_real -= point2_real; - point1_imag -= point2_imag; - - // x[i1] = x[i] + x[i2] - Real[i] += point2_real; - Imag[i] += point2_imag; - - // x[i2] = (x[i] - x[i2]) * w - Real[i2] = (MUL_F(point1_real,w_real) - MUL_F(point1_imag,w_imag)); - Imag[i2] = (MUL_F(point1_real,w_imag) + MUL_F(point1_imag,w_real)); - } - - // Stage 3 of 32 point FFT decimation in frequency - // 2*4*2=16 multiplications - // 4*4*2+6*4*2=10*8=80 additions - for (i = 0; i < n; i += 8) - { - i2 = i+4; - point1_real = Real[i]; - point1_imag = Imag[i]; - - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // out[i1] = point1 + point2 - Real[i] += point2_real; - Imag[i] += point2_imag; - - // out[i2] = point1 - point2 - Real[i2] = point1_real - point2_real; - Imag[i2] = point1_imag - point2_imag; - } - w_real = w_array_real[4]; // = sqrt(2)/2 - // w_imag = -w_real; // = w_array_imag[4]; // = -sqrt(2)/2 - for (i = 1; i < n; i += 8) - { - i2 = i+4; - point1_real = Real[i]; - point1_imag = Imag[i]; - - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // temp1 = x[i] - x[i2] - point1_real -= point2_real; - point1_imag -= point2_imag; - - // x[i1] = x[i] + x[i2] - Real[i] += point2_real; - Imag[i] += point2_imag; - - // x[i2] = (x[i] - x[i2]) * w - Real[i2] = MUL_F(point1_real+point1_imag, w_real); - Imag[i2] = MUL_F(point1_imag-point1_real, w_real); - } - for (i = 2; i < n; i += 8) - { - i2 = i+4; - point1_real = Real[i]; - point1_imag = Imag[i]; - - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // x[i] = x[i] + x[i2] - Real[i] += point2_real; - Imag[i] += point2_imag; - - // x[i2] = (x[i] - x[i2]) * (-i) - Real[i2] = point1_imag - point2_imag; - Imag[i2] = point2_real - point1_real; - } - w_real = w_array_real[12]; // = -sqrt(2)/2 - // w_imag = w_real; // = w_array_imag[12]; // = -sqrt(2)/2 - for (i = 3; i < n; i += 8) - { - i2 = i+4; - point1_real = Real[i]; - point1_imag = Imag[i]; - - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // temp1 = x[i] - x[i2] - point1_real -= point2_real; - point1_imag -= point2_imag; - - // x[i1] = x[i] + x[i2] - Real[i] += point2_real; - Imag[i] += point2_imag; - - // x[i2] = (x[i] - x[i2]) * w - Real[i2] = MUL_F(point1_real-point1_imag, w_real); - Imag[i2] = MUL_F(point1_real+point1_imag, w_real); - } - - - // Stage 4 of 32 point FFT decimation in frequency (no multiplications) - // 16*4=64 additions - for (i = 0; i < n; i += 4) - { - i2 = i+2; - point1_real = Real[i]; - point1_imag = Imag[i]; - - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // x[i1] = x[i] + x[i2] - Real[i] += point2_real; - Imag[i] += point2_imag; - - // x[i2] = x[i] - x[i2] - Real[i2] = point1_real - point2_real; - Imag[i2] = point1_imag - point2_imag; - } - for (i = 1; i < n; i += 4) - { - i2 = i+2; - point1_real = Real[i]; - point1_imag = Imag[i]; - - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // x[i] = x[i] + x[i2] - Real[i] += point2_real; - Imag[i] += point2_imag; - - // x[i2] = (x[i] - x[i2]) * (-i) - Real[i2] = point1_imag - point2_imag; - Imag[i2] = point2_real - point1_real; - } - - // Stage 5 of 32 point FFT decimation in frequency (no multiplications) - // 16*4=64 additions - for (i = 0; i < n; i += 2) - { - i2 = i+1; - point1_real = Real[i]; - point1_imag = Imag[i]; - - point2_real = Real[i2]; - point2_imag = Imag[i2]; - - // out[i1] = point1 + point2 - Real[i] += point2_real; - Imag[i] += point2_imag; - - // out[i2] = point1 - point2 - Real[i2] = point1_real - point2_real; - Imag[i2] = point1_imag - point2_imag; - } - -#ifdef REORDER_IN_FFT - FFTReorder(Real, Imag); -#endif // #ifdef REORDER_IN_FFT -} -#undef n -#undef log2n - -static const real_t dct4_64_tab[] = { - COEF_CONST(0.999924719333649), COEF_CONST(0.998118102550507), - COEF_CONST(0.993906974792480), COEF_CONST(0.987301409244537), - COEF_CONST(0.978317379951477), COEF_CONST(0.966976463794708), - COEF_CONST(0.953306019306183), COEF_CONST(0.937339007854462), - COEF_CONST(0.919113874435425), COEF_CONST(0.898674488067627), - COEF_CONST(0.876070082187653), COEF_CONST(0.851355195045471), - COEF_CONST(0.824589252471924), COEF_CONST(0.795836925506592), - COEF_CONST(0.765167236328125), COEF_CONST(0.732654273509979), - COEF_CONST(0.698376238346100), COEF_CONST(0.662415742874146), - COEF_CONST(0.624859452247620), COEF_CONST(0.585797846317291), - COEF_CONST(0.545324981212616), COEF_CONST(0.503538429737091), - COEF_CONST(0.460538715124130), COEF_CONST(0.416429549455643), - COEF_CONST(0.371317148208618), COEF_CONST(0.325310230255127), - COEF_CONST(0.278519600629807), COEF_CONST(0.231058135628700), - COEF_CONST(0.183039888739586), COEF_CONST(0.134580686688423), - COEF_CONST(0.085797272622585), COEF_CONST(0.036807164549828), - COEF_CONST(-1.012196302413940), COEF_CONST(-1.059438824653626), - COEF_CONST(-1.104129195213318), COEF_CONST(-1.146159529685974), - COEF_CONST(-1.185428738594055), COEF_CONST(-1.221842169761658), - COEF_CONST(-1.255311965942383), COEF_CONST(-1.285757660865784), - COEF_CONST(-1.313105940818787), COEF_CONST(-1.337290763854981), - COEF_CONST(-1.358253836631775), COEF_CONST(-1.375944852828980), - COEF_CONST(-1.390321016311646), COEF_CONST(-1.401347875595093), - COEF_CONST(-1.408998727798462), COEF_CONST(-1.413255214691162), - COEF_CONST(-1.414107084274292), COEF_CONST(-1.411552190780640), - COEF_CONST(-1.405596733093262), COEF_CONST(-1.396255016326904), - COEF_CONST(-1.383549690246582), COEF_CONST(-1.367511272430420), - COEF_CONST(-1.348178386688232), COEF_CONST(-1.325597524642944), - COEF_CONST(-1.299823284149170), COEF_CONST(-1.270917654037476), - COEF_CONST(-1.238950133323669), COEF_CONST(-1.203998088836670), - COEF_CONST(-1.166145324707031), COEF_CONST(-1.125483393669128), - COEF_CONST(-1.082109928131104), COEF_CONST(-1.036129593849182), - COEF_CONST(-0.987653195858002), COEF_CONST(-0.936797380447388), - COEF_CONST(-0.883684754371643), COEF_CONST(-0.828443288803101), - COEF_CONST(-0.771206021308899), COEF_CONST(-0.712110757827759), - COEF_CONST(-0.651300072669983), COEF_CONST(-0.588920354843140), - COEF_CONST(-0.525121808052063), COEF_CONST(-0.460058242082596), - COEF_CONST(-0.393886327743530), COEF_CONST(-0.326765477657318), - COEF_CONST(-0.258857429027557), COEF_CONST(-0.190325915813446), - COEF_CONST(-0.121335685253143), COEF_CONST(-0.052053272724152), - COEF_CONST(0.017354607582092), COEF_CONST(0.086720645427704), - COEF_CONST(0.155877828598022), COEF_CONST(0.224659323692322), - COEF_CONST(0.292899727821350), COEF_CONST(0.360434412956238), - COEF_CONST(0.427100926637650), COEF_CONST(0.492738455533981), - COEF_CONST(0.557188928127289), COEF_CONST(0.620297133922577), - COEF_CONST(0.681910991668701), COEF_CONST(0.741881847381592), - COEF_CONST(0.800065577030182), COEF_CONST(0.856321990489960), - COEF_CONST(0.910515367984772), COEF_CONST(0.962515234947205), - COEF_CONST(1.000000000000000), COEF_CONST(0.998795449733734), - COEF_CONST(0.995184719562531), COEF_CONST(0.989176511764526), - COEF_CONST(0.980785250663757), COEF_CONST(0.970031261444092), - COEF_CONST(0.956940352916718), COEF_CONST(0.941544055938721), - COEF_CONST(0.923879504203796), COEF_CONST(0.903989315032959), - COEF_CONST(0.881921231746674), COEF_CONST(0.857728600502014), - COEF_CONST(0.831469595432281), COEF_CONST(0.803207516670227), - COEF_CONST(0.773010432720184), COEF_CONST(0.740951120853424), - COEF_CONST(0.707106769084930), COEF_CONST(0.671558916568756), - COEF_CONST(0.634393274784088), COEF_CONST(0.595699310302734), - COEF_CONST(0.555570185184479), COEF_CONST(0.514102697372437), - COEF_CONST(0.471396654844284), COEF_CONST(0.427555114030838), - COEF_CONST(0.382683426141739), COEF_CONST(0.336889833211899), - COEF_CONST(0.290284633636475), COEF_CONST(0.242980122566223), - COEF_CONST(0.195090234279633), COEF_CONST(0.146730497479439), - COEF_CONST(0.098017133772373), COEF_CONST(0.049067649990320), - COEF_CONST(-1.000000000000000), COEF_CONST(-1.047863125801086), - COEF_CONST(-1.093201875686646), COEF_CONST(-1.135906934738159), - COEF_CONST(-1.175875544548035), COEF_CONST(-1.213011503219605), - COEF_CONST(-1.247225046157837), COEF_CONST(-1.278433918952942), - COEF_CONST(-1.306562900543213), COEF_CONST(-1.331544399261475), - COEF_CONST(-1.353317975997925), COEF_CONST(-1.371831417083740), - COEF_CONST(-1.387039899826050), COEF_CONST(-1.398906826972961), - COEF_CONST(-1.407403707504273), COEF_CONST(-1.412510156631470), - COEF_CONST(0), COEF_CONST(-1.412510156631470), - COEF_CONST(-1.407403707504273), COEF_CONST(-1.398906826972961), - COEF_CONST(-1.387039899826050), COEF_CONST(-1.371831417083740), - COEF_CONST(-1.353317975997925), COEF_CONST(-1.331544399261475), - COEF_CONST(-1.306562900543213), COEF_CONST(-1.278433918952942), - COEF_CONST(-1.247225046157837), COEF_CONST(-1.213011384010315), - COEF_CONST(-1.175875544548035), COEF_CONST(-1.135907053947449), - COEF_CONST(-1.093201875686646), COEF_CONST(-1.047863125801086), - COEF_CONST(-1.000000000000000), COEF_CONST(-0.949727773666382), - COEF_CONST(-0.897167563438416), COEF_CONST(-0.842446029186249), - COEF_CONST(-0.785694956779480), COEF_CONST(-0.727051079273224), - COEF_CONST(-0.666655659675598), COEF_CONST(-0.604654192924500), - COEF_CONST(-0.541196048259735), COEF_CONST(-0.476434230804443), - COEF_CONST(-0.410524487495422), COEF_CONST(-0.343625843524933), - COEF_CONST(-0.275899350643158), COEF_CONST(-0.207508206367493), - COEF_CONST(-0.138617098331451), COEF_CONST(-0.069392144680023), - COEF_CONST(0), COEF_CONST(0.069392263889313), - COEF_CONST(0.138617157936096), COEF_CONST(0.207508206367493), - COEF_CONST(0.275899469852448), COEF_CONST(0.343625962734222), - COEF_CONST(0.410524636507034), COEF_CONST(0.476434201002121), - COEF_CONST(0.541196107864380), COEF_CONST(0.604654192924500), - COEF_CONST(0.666655719280243), COEF_CONST(0.727051138877869), - COEF_CONST(0.785695075988770), COEF_CONST(0.842446029186249), - COEF_CONST(0.897167563438416), COEF_CONST(0.949727773666382) -}; - -/* size 64 only! */ -void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_imag) -{ - // Tables with bit reverse values for 5 bits, bit reverse of i at i-th position - const uint8_t bit_rev_tab[32] = { 0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31 }; - uint16_t i, i_rev; - - /* Step 2: modulate */ - // 3*32=96 multiplications - // 3*32=96 additions - for (i = 0; i < 32; i++) - { - real_t x_re, x_im, tmp; - x_re = in_real[i]; - x_im = in_imag[i]; - tmp = MUL_C(x_re + x_im, dct4_64_tab[i]); - in_real[i] = MUL_C(x_im, dct4_64_tab[i + 64]) + tmp; - in_imag[i] = MUL_C(x_re, dct4_64_tab[i + 32]) + tmp; - } - - /* Step 3: FFT, but with output in bit reverse order */ - fft_dif(in_real, in_imag); - - /* Step 4: modulate + bitreverse reordering */ - // 3*31+2=95 multiplications - // 3*31+2=95 additions - for (i = 0; i < 16; i++) - { - real_t x_re, x_im, tmp; - i_rev = bit_rev_tab[i]; - x_re = in_real[i_rev]; - x_im = in_imag[i_rev]; - - tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]); - out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp; - out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4*32]) + tmp; - } - // i = 16, i_rev = 1 = rev(16); - out_imag[16] = MUL_C(in_imag[1] - in_real[1], dct4_64_tab[16 + 3*32]); - out_real[16] = MUL_C(in_real[1] + in_imag[1], dct4_64_tab[16 + 3*32]); - for (i = 17; i < 32; i++) - { - real_t x_re, x_im, tmp; - i_rev = bit_rev_tab[i]; - x_re = in_real[i_rev]; - x_im = in_imag[i_rev]; - tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]); - out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp; - out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4*32]) + tmp; - } - + f128 = f65 - f108; + f129 = f65 + f108; + f130 = f67 - f114; + f131 = f67 + f114; + f132 = f69 - f120; + f133 = f69 + f120; + f134 = f71 - f126; + f135 = f71 + f126; + f136 = f70 - f127; + f137 = f70 + f127; + f138 = f68 - f121; + f139 = f68 + f121; + f140 = f66 - f115; + f141 = f66 + f115; + f142 = f64 - f109; + f143 = f64 + f109; + f144 = f0 + f30; + f145 = MUL_C(COEF_CONST(1.0478631305325901), f0); + f146 = MUL_F(FRAC_CONST(-0.9987954562051724), f144); + f147 = MUL_F(FRAC_CONST(-0.9497277818777548), f30); + f148 = f145 + f146; + f149 = f147 - f146; + f150 = f4 + f26; + f151 = MUL_F(FRAC_CONST(1.2130114330978077), f4); + f152 = MUL_F(FRAC_CONST(-0.9700312531945440), f150); + f153 = MUL_F(FRAC_CONST(-0.7270510732912803), f26); + f154 = f151 + f152; + f155 = f153 - f152; + f156 = f8 + f22; + f157 = MUL_C(COEF_CONST(1.3315443865537255), f8); + f158 = MUL_F(FRAC_CONST(-0.9039892931234433), f156); + f159 = MUL_F(FRAC_CONST(-0.4764341996931612), f22); + f160 = f157 + f158; + f161 = f159 - f158; + f162 = f12 + f18; + f163 = MUL_C(COEF_CONST(1.3989068359730781), f12); + f164 = MUL_F(FRAC_CONST(-0.8032075314806453), f162); + f165 = MUL_F(FRAC_CONST(-0.2075082269882124), f18); + f166 = f163 + f164; + f167 = f165 - f164; + f168 = f16 + f14; + f169 = MUL_C(COEF_CONST(1.4125100802019777), f16); + f170 = MUL_F(FRAC_CONST(-0.6715589548470187), f168); + f171 = MUL_F(FRAC_CONST(0.0693921705079402), f14); + f172 = f169 + f170; + f173 = f171 - f170; + f174 = f20 + f10; + f175 = MUL_C(COEF_CONST(1.3718313541934939), f20); + f176 = MUL_F(FRAC_CONST(-0.5141027441932219), f174); + f177 = MUL_F(FRAC_CONST(0.3436258658070501), f10); + f178 = f175 + f176; + f179 = f177 - f176; + f180 = f24 + f6; + f181 = MUL_C(COEF_CONST(1.2784339185752409), f24); + f182 = MUL_F(FRAC_CONST(-0.3368898533922200), f180); + f183 = MUL_F(FRAC_CONST(0.6046542117908008), f6); + f184 = f181 + f182; + f185 = f183 - f182; + f186 = f28 + f2; + f187 = MUL_C(COEF_CONST(1.1359069844201433), f28); + f188 = MUL_F(FRAC_CONST(-0.1467304744553624), f186); + f189 = MUL_F(FRAC_CONST(0.8424460355094185), f2); + f190 = f187 + f188; + f191 = f189 - f188; + f192 = f149 - f173; + f193 = f149 + f173; + f194 = f148 - f172; + f195 = f148 + f172; + f196 = f155 - f179; + f197 = f155 + f179; + f198 = f154 - f178; + f199 = f154 + f178; + f200 = f161 - f185; + f201 = f161 + f185; + f202 = f160 - f184; + f203 = f160 + f184; + f204 = f167 - f191; + f205 = f167 + f191; + f206 = f166 - f190; + f207 = f166 + f190; + f208 = f192 + f194; + f209 = MUL_C(COEF_CONST(1.1758756024193588), f192); + f210 = MUL_F(FRAC_CONST(-0.9807852804032304), f208); + f211 = MUL_F(FRAC_CONST(-0.7856949583871021), f194); + f212 = f209 + f210; + f213 = f211 - f210; + f214 = f196 + f198; + f215 = MUL_C(COEF_CONST(1.3870398453221475), f196); + f216 = MUL_F(FRAC_CONST(-0.5555702330196022), f214); + f217 = MUL_F(FRAC_CONST(0.2758993792829431), f198); + f218 = f215 + f216; + f219 = f217 - f216; + f220 = f200 + f202; + f221 = MUL_F(FRAC_CONST(0.7856949583871022), f200); + f222 = MUL_F(FRAC_CONST(0.1950903220161283), f220); + f223 = MUL_C(COEF_CONST(1.1758756024193586), f202); + f224 = f221 + f222; + f225 = f223 - f222; + f226 = f204 + f206; + f227 = MUL_F(FRAC_CONST(-0.2758993792829430), f204); + f228 = MUL_F(FRAC_CONST(0.8314696123025452), f226); + f229 = MUL_C(COEF_CONST(1.3870398453221475), f206); + f230 = f227 + f228; + f231 = f229 - f228; + f232 = f193 - f201; + f233 = f193 + f201; + f234 = f195 - f203; + f235 = f195 + f203; + f236 = f197 - f205; + f237 = f197 + f205; + f238 = f199 - f207; + f239 = f199 + f207; + f240 = f213 - f225; + f241 = f213 + f225; + f242 = f212 - f224; + f243 = f212 + f224; + f244 = f219 - f231; + f245 = f219 + f231; + f246 = f218 - f230; + f247 = f218 + f230; + f248 = f232 + f234; + f249 = MUL_C(COEF_CONST(1.3065629648763766), f232); + f250 = MUL_F(FRAC_CONST(-0.9238795325112866), f248); + f251 = MUL_F(FRAC_CONST(-0.5411961001461967), f234); + f252 = f249 + f250; + f253 = f251 - f250; + f254 = f236 + f238; + f255 = MUL_F(FRAC_CONST(0.5411961001461969), f236); + f256 = MUL_F(FRAC_CONST(0.3826834323650898), f254); + f257 = MUL_C(COEF_CONST(1.3065629648763766), f238); + f258 = f255 + f256; + f259 = f257 - f256; + f260 = f240 + f242; + f261 = MUL_C(COEF_CONST(1.3065629648763766), f240); + f262 = MUL_F(FRAC_CONST(-0.9238795325112866), f260); + f263 = MUL_F(FRAC_CONST(-0.5411961001461967), f242); + f264 = f261 + f262; + f265 = f263 - f262; + f266 = f244 + f246; + f267 = MUL_F(FRAC_CONST(0.5411961001461969), f244); + f268 = MUL_F(FRAC_CONST(0.3826834323650898), f266); + f269 = MUL_C(COEF_CONST(1.3065629648763766), f246); + f270 = f267 + f268; + f271 = f269 - f268; + f272 = f233 - f237; + f273 = f233 + f237; + f274 = f235 - f239; + f275 = f235 + f239; + f276 = f253 - f259; + f277 = f253 + f259; + f278 = f252 - f258; + f279 = f252 + f258; + f280 = f241 - f245; + f281 = f241 + f245; + f282 = f243 - f247; + f283 = f243 + f247; + f284 = f265 - f271; + f285 = f265 + f271; + f286 = f264 - f270; + f287 = f264 + f270; + f288 = f272 - f274; + f289 = f272 + f274; + f290 = MUL_F(FRAC_CONST(0.7071067811865474), f288); + f291 = MUL_F(FRAC_CONST(0.7071067811865474), f289); + f292 = f276 - f278; + f293 = f276 + f278; + f294 = MUL_F(FRAC_CONST(0.7071067811865474), f292); + f295 = MUL_F(FRAC_CONST(0.7071067811865474), f293); + f296 = f280 - f282; + f297 = f280 + f282; + f298 = MUL_F(FRAC_CONST(0.7071067811865474), f296); + f299 = MUL_F(FRAC_CONST(0.7071067811865474), f297); + f300 = f284 - f286; + f301 = f284 + f286; + f302 = MUL_F(FRAC_CONST(0.7071067811865474), f300); + f303 = MUL_F(FRAC_CONST(0.7071067811865474), f301); + f304 = f129 - f273; + f305 = f129 + f273; + f306 = f131 - f281; + f307 = f131 + f281; + f308 = f133 - f285; + f309 = f133 + f285; + f310 = f135 - f277; + f311 = f135 + f277; + f312 = f137 - f295; + f313 = f137 + f295; + f314 = f139 - f303; + f315 = f139 + f303; + f316 = f141 - f299; + f317 = f141 + f299; + f318 = f143 - f291; + f319 = f143 + f291; + f320 = f142 - f290; + f321 = f142 + f290; + f322 = f140 - f298; + f323 = f140 + f298; + f324 = f138 - f302; + f325 = f138 + f302; + f326 = f136 - f294; + f327 = f136 + f294; + f328 = f134 - f279; + f329 = f134 + f279; + f330 = f132 - f287; + f331 = f132 + f287; + f332 = f130 - f283; + f333 = f130 + f283; + f334 = f128 - f275; + f335 = f128 + f275; + y[31] = MUL_F(FRAC_CONST(0.5001506360206510), f305); + y[30] = MUL_F(FRAC_CONST(0.5013584524464084), f307); + y[29] = MUL_F(FRAC_CONST(0.5037887256810443), f309); + y[28] = MUL_F(FRAC_CONST(0.5074711720725553), f311); + y[27] = MUL_F(FRAC_CONST(0.5124514794082247), f313); + y[26] = MUL_F(FRAC_CONST(0.5187927131053328), f315); + y[25] = MUL_F(FRAC_CONST(0.5265773151542700), f317); + y[24] = MUL_F(FRAC_CONST(0.5359098169079920), f319); + y[23] = MUL_F(FRAC_CONST(0.5469204379855088), f321); + y[22] = MUL_F(FRAC_CONST(0.5597698129470802), f323); + y[21] = MUL_F(FRAC_CONST(0.5746551840326600), f325); + y[20] = MUL_F(FRAC_CONST(0.5918185358574165), f327); + y[19] = MUL_F(FRAC_CONST(0.6115573478825099), f329); + y[18] = MUL_F(FRAC_CONST(0.6342389366884031), f331); + y[17] = MUL_F(FRAC_CONST(0.6603198078137061), f333); + y[16] = MUL_F(FRAC_CONST(0.6903721282002123), f335); + y[15] = MUL_F(FRAC_CONST(0.7251205223771985), f334); + y[14] = MUL_F(FRAC_CONST(0.7654941649730891), f332); + y[13] = MUL_F(FRAC_CONST(0.8127020908144905), f330); + y[12] = MUL_F(FRAC_CONST(0.8683447152233481), f328); + y[11] = MUL_F(FRAC_CONST(0.9345835970364075), f326); + y[10] = MUL_C(COEF_CONST(1.0144082649970547), f324); + y[9] = MUL_C(COEF_CONST(1.1120716205797176), f322); + y[8] = MUL_C(COEF_CONST(1.2338327379765710), f320); + y[7] = MUL_C(COEF_CONST(1.3892939586328277), f318); + y[6] = MUL_C(COEF_CONST(1.5939722833856311), f316); + y[5] = MUL_C(COEF_CONST(1.8746759800084078), f314); + y[4] = MUL_C(COEF_CONST(2.2820500680051619), f312); + y[3] = MUL_C(COEF_CONST(2.9246284281582162), f310); + y[2] = MUL_C(COEF_CONST(4.0846110781292477), f308); + y[1] = MUL_C(COEF_CONST(6.7967507116736332), f306); + y[0] = MUL_R(REAL_CONST(20.3738781672314530), f304); } -void DST4_32(real_t *y, real_t *x) +#ifdef SBR_LOW_POWER + +void DCT2_16_unscaled(real_t *y, real_t *x) { - real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9; - real_t f10, f11, f12, f13, f14, f15, f16, f17, f18, f19; - real_t f20, f21, f22, f23, f24, f25, f26, f27, f28, f29; - real_t f30, f31, f32, f33, f34, f35, f36, f37, f38, f39; - real_t f40, f41, f42, f43, f44, f45, f46, f47, f48, f49; - real_t f50, f51, f52, f53, f54, f55, f56, f57, f58, f59; - real_t f60, f61, f62, f63, f64, f65, f66, f67, f68, f69; - real_t f70, f71, f72, f73, f74, f75, f76, f77, f78, f79; - real_t f80, f81, f82, f83, f84, f85, f86, f87, f88, f89; - real_t f90, f91, f92, f93, f94, f95, f96, f97, f98, f99; - real_t f100, f101, f102, f103, f104, f105, f106, f107, f108, f109; - real_t f110, f111, f112, f113, f114, f115, f116, f117, f118, f119; - real_t f120, f121, f122, f123, f124, f125, f126, f127, f128, f129; - real_t f130, f131, f132, f133, f134, f135, f136, f137, f138, f139; - real_t f140, f141, f142, f143, f144, f145, f146, f147, f148, f149; - real_t f150, f151, f152, f153, f154, f155, f156, f157, f158, f159; - real_t f160, f161, f162, f163, f164, f165, f166, f167, f168, f169; - real_t f170, f171, f172, f173, f174, f175, f176, f177, f178, f179; - real_t f180, f181, f182, f183, f184, f185, f186, f187, f188, f189; - real_t f190, f191, f192, f193, f194, f195, f196, f197, f198, f199; - real_t f200, f201, f202, f203, f204, f205, f206, f207, f208, f209; - real_t f210, f211, f212, f213, f214, f215, f216, f217, f218, f219; - real_t f220, f221, f222, f223, f224, f225, f226, f227, f228, f229; - real_t f230, f231, f232, f233, f234, f235, f236, f237, f238, f239; - real_t f240, f241, f242, f243, f244, f245, f246, f247, f248, f249; - real_t f250, f251, f252, f253, f254, f255, f256, f257, f258, f259; - real_t f260, f261, f262, f263, f264, f265, f266, f267, f268, f269; - real_t f270, f271, f272, f273, f274, f275, f276, f277, f278, f279; - real_t f280, f281, f282, f283, f284, f285, f286, f287, f288, f289; - real_t f290, f291, f292, f293, f294, f295, f296, f297, f298, f299; - real_t f300, f301, f302, f303, f304, f305, f306, f307, f308, f309; - real_t f310, f311, f312, f313, f314, f315, f316, f317, f318, f319; - real_t f320, f321, f322, f323, f324, f325, f326, f327, f328, f329; - real_t f330, f331, f332, f333, f334, f335; + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f31, f32; + real_t f33, f34, f37, f38, f39, f40, f41, f42, f43, f44; + real_t f45, f46, f47, f48, f49, f51, f53, f54, f57, f58; + real_t f59, f60, f61, f62, f63, f64, f65, f66, f67, f68; + real_t f69, f70, f71, f72, f73, f74, f75, f76, f77, f78; + real_t f79, f80, f81, f82, f83, f84, f85, f86, f87, f88; + real_t f89, f90, f91, f92, f95, f96, f97, f98, f101, f102; + real_t f103, f104, f107, f108, f109, f110; - f0 = x[0] - x[1]; - f1 = x[2] - x[1]; - f2 = x[2] - x[3]; - f3 = x[4] - x[3]; - f4 = x[4] - x[5]; - f5 = x[6] - x[5]; - f6 = x[6] - x[7]; - f7 = x[8] - x[7]; - f8 = x[8] - x[9]; - f9 = x[10] - x[9]; - f10 = x[10] - x[11]; - f11 = x[12] - x[11]; - f12 = x[12] - x[13]; - f13 = x[14] - x[13]; - f14 = x[14] - x[15]; - f15 = x[16] - x[15]; - f16 = x[16] - x[17]; - f17 = x[18] - x[17]; - f18 = x[18] - x[19]; - f19 = x[20] - x[19]; - f20 = x[20] - x[21]; - f21 = x[22] - x[21]; - f22 = x[22] - x[23]; - f23 = x[24] - x[23]; - f24 = x[24] - x[25]; - f25 = x[26] - x[25]; - f26 = x[26] - x[27]; - f27 = x[28] - x[27]; - f28 = x[28] - x[29]; - f29 = x[30] - x[29]; - f30 = x[30] - x[31]; - f31 = MUL_F(FRAC_CONST(0.7071067811865476), f15); - f32 = x[0] - f31; - f33 = x[0] + f31; - f34 = f7 + f23; - f35 = MUL_C(COEF_CONST(1.3065629648763766), f7); - f36 = MUL_F(FRAC_CONST(-0.9238795325112866), f34); - f37 = MUL_F(FRAC_CONST(-0.5411961001461967), f23); - f38 = f35 + f36; - f39 = f37 - f36; - f40 = f33 - f39; - f41 = f33 + f39; - f42 = f32 - f38; - f43 = f32 + f38; - f44 = f11 - f19; - f45 = f11 + f19; - f46 = MUL_F(FRAC_CONST(0.7071067811865476), f45); - f47 = f3 - f46; - f48 = f3 + f46; - f49 = MUL_F(FRAC_CONST(0.7071067811865476), f44); - f50 = f49 - f27; - f51 = f49 + f27; - f52 = f51 + f48; - f53 = MUL_F(FRAC_CONST(-0.7856949583871021), f51); - f54 = MUL_F(FRAC_CONST(0.9807852804032304), f52); - f55 = MUL_C(COEF_CONST(1.1758756024193588), f48); - f56 = f53 + f54; - f57 = f55 - f54; - f58 = f50 + f47; - f59 = MUL_F(FRAC_CONST(-0.2758993792829430), f50); - f60 = MUL_F(FRAC_CONST(0.8314696123025452), f58); - f61 = MUL_C(COEF_CONST(1.3870398453221475), f47); - f62 = f59 + f60; - f63 = f61 - f60; - f64 = f41 - f56; - f65 = f41 + f56; - f66 = f43 - f62; - f67 = f43 + f62; - f68 = f42 - f63; - f69 = f42 + f63; - f70 = f40 - f57; - f71 = f40 + f57; - f72 = f5 - f9; - f73 = f5 + f9; - f74 = f13 - f17; - f75 = f13 + f17; - f76 = f21 - f25; - f77 = f21 + f25; - f78 = MUL_F(FRAC_CONST(0.7071067811865476), f75); - f79 = f1 - f78; - f80 = f1 + f78; - f81 = f73 + f77; - f82 = MUL_C(COEF_CONST(1.3065629648763766), f73); - f83 = MUL_F(FRAC_CONST(-0.9238795325112866), f81); - f84 = MUL_F(FRAC_CONST(-0.5411961001461967), f77); - f85 = f82 + f83; - f86 = f84 - f83; - f87 = f80 - f86; - f88 = f80 + f86; - f89 = f79 - f85; - f90 = f79 + f85; - f91 = MUL_F(FRAC_CONST(0.7071067811865476), f74); - f92 = f29 - f91; - f93 = f29 + f91; - f94 = f76 + f72; - f95 = MUL_C(COEF_CONST(1.3065629648763766), f76); - f96 = MUL_F(FRAC_CONST(-0.9238795325112866), f94); - f97 = MUL_F(FRAC_CONST(-0.5411961001461967), f72); - f98 = f95 + f96; - f99 = f97 - f96; - f100 = f93 - f99; - f101 = f93 + f99; - f102 = f92 - f98; - f103 = f92 + f98; - f104 = f101 + f88; - f105 = MUL_F(FRAC_CONST(-0.8971675863426361), f101); - f106 = MUL_F(FRAC_CONST(0.9951847266721968), f104); - f107 = MUL_C(COEF_CONST(1.0932018670017576), f88); + f0 = x[0] - x[15]; + f1 = x[0] + x[15]; + f2 = x[1] - x[14]; + f3 = x[1] + x[14]; + f4 = x[2] - x[13]; + f5 = x[2] + x[13]; + f6 = x[3] - x[12]; + f7 = x[3] + x[12]; + f8 = x[4] - x[11]; + f9 = x[4] + x[11]; + f10 = x[5] - x[10]; + f11 = x[5] + x[10]; + f12 = x[6] - x[9]; + f13 = x[6] + x[9]; + f14 = x[7] - x[8]; + f15 = x[7] + x[8]; + f16 = f1 - f15; + f17 = f1 + f15; + f18 = f3 - f13; + f19 = f3 + f13; + f20 = f5 - f11; + f21 = f5 + f11; + f22 = f7 - f9; + f23 = f7 + f9; + f24 = f17 - f23; + f25 = f17 + f23; + f26 = f19 - f21; + f27 = f19 + f21; + f28 = f25 - f27; + y[0] = f25 + f27; + y[8] = MUL_F(f28, FRAC_CONST(0.7071067811865476)); + f31 = f24 + f26; + f32 = MUL_C(f24, COEF_CONST(1.3065629648763766)); + f33 = MUL_F(f31, FRAC_CONST(-0.9238795325112866)); + f34 = MUL_F(f26, FRAC_CONST(-0.5411961001461967)); + y[12] = f32 + f33; + y[4] = f34 - f33; + f37 = f16 + f22; + f38 = MUL_C(f16, COEF_CONST(1.1758756024193588)); + f39 = MUL_F(f37, FRAC_CONST(-0.9807852804032304)); + f40 = MUL_F(f22, FRAC_CONST(-0.7856949583871021)); + f41 = f38 + f39; + f42 = f40 - f39; + f43 = f18 + f20; + f44 = MUL_C(f18, COEF_CONST(1.3870398453221473)); + f45 = MUL_F(f43, FRAC_CONST(-0.8314696123025455)); + f46 = MUL_F(f20, FRAC_CONST(-0.2758993792829436)); + f47 = f44 + f45; + f48 = f46 - f45; + f49 = f42 - f48; + y[2] = f42 + f48; + f51 = MUL_F(f49, FRAC_CONST(0.7071067811865476)); + y[14] = f41 - f47; + f53 = f41 + f47; + f54 = MUL_F(f53, FRAC_CONST(0.7071067811865476)); + y[10] = f51 - f54; + y[6] = f51 + f54; + f57 = f2 - f4; + f58 = f2 + f4; + f59 = f6 - f8; + f60 = f6 + f8; + f61 = f10 - f12; + f62 = f10 + f12; + f63 = MUL_F(f60, FRAC_CONST(0.7071067811865476)); + f64 = f0 - f63; + f65 = f0 + f63; + f66 = f58 + f62; + f67 = MUL_C(f58, COEF_CONST(1.3065629648763766)); + f68 = MUL_F(f66, FRAC_CONST(-0.9238795325112866)); + f69 = MUL_F(f62, FRAC_CONST(-0.5411961001461967)); + f70 = f67 + f68; + f71 = f69 - f68; + f72 = f65 - f71; + f73 = f65 + f71; + f74 = f64 - f70; + f75 = f64 + f70; + f76 = MUL_F(f59, FRAC_CONST(0.7071067811865476)); + f77 = f14 - f76; + f78 = f14 + f76; + f79 = f61 + f57; + f80 = MUL_C(f61, COEF_CONST(1.3065629648763766)); + f81 = MUL_F(f79, FRAC_CONST(-0.9238795325112866)); + f82 = MUL_F(f57, FRAC_CONST(-0.5411961001461967)); + f83 = f80 + f81; + f84 = f82 - f81; + f85 = f78 - f84; + f86 = f78 + f84; + f87 = f77 - f83; + f88 = f77 + f83; + f89 = f86 + f73; + f90 = MUL_F(f86, FRAC_CONST(-0.8971675863426361)); + f91 = MUL_F(f89, FRAC_CONST(0.9951847266721968)); + f92 = MUL_C(f73, COEF_CONST(1.0932018670017576)); + y[1] = f90 + f91; + y[15] = f92 - f91; + f95 = f75 - f88; + f96 = MUL_F(f88, FRAC_CONST(-0.6666556584777466)); + f97 = MUL_F(f95, FRAC_CONST(0.9569403357322089)); + f98 = MUL_C(f75, COEF_CONST(1.2472250129866713)); + y[3] = f97 - f96; + y[13] = f98 - f97; + f101 = f87 + f74; + f102 = MUL_F(f87, FRAC_CONST(-0.4105245275223571)); + f103 = MUL_F(f101, FRAC_CONST(0.8819212643483549)); + f104 = MUL_C(f74, COEF_CONST(1.3533180011743529)); + y[5] = f102 + f103; + y[11] = f104 - f103; + f107 = f72 - f85; + f108 = MUL_F(f85, FRAC_CONST(-0.1386171691990915)); + f109 = MUL_F(f107, FRAC_CONST(0.7730104533627370)); + f110 = MUL_C(f72, COEF_CONST(1.4074037375263826)); + y[7] = f109 - f108; + y[9] = f110 - f109; +} + +void DCT4_16(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; + real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; + real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; + real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; + real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; + real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; + real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; + real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; + real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; + real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; + real_t f121, f122, f123, f124, f125, f126, f127, f128, f130, f132; + real_t f134, f136, f138, f140, f142, f144, f145, f148, f149, f152; + real_t f153, f156, f157; + + f0 = x[0] + x[15]; + f1 = MUL_C(COEF_CONST(1.0478631305325901), x[0]); + f2 = MUL_F(FRAC_CONST(-0.9987954562051724), f0); + f3 = MUL_F(FRAC_CONST(-0.9497277818777548), x[15]); + f4 = f1 + f2; + f5 = f3 - f2; + f6 = x[2] + x[13]; + f7 = MUL_C(COEF_CONST(1.2130114330978077), x[2]); + f8 = MUL_F(FRAC_CONST(-0.9700312531945440), f6); + f9 = MUL_F(FRAC_CONST(-0.7270510732912803), x[13]); + f10 = f7 + f8; + f11 = f9 - f8; + f12 = x[4] + x[11]; + f13 = MUL_C(COEF_CONST(1.3315443865537255), x[4]); + f14 = MUL_F(FRAC_CONST(-0.9039892931234433), f12); + f15 = MUL_F(FRAC_CONST(-0.4764341996931612), x[11]); + f16 = f13 + f14; + f17 = f15 - f14; + f18 = x[6] + x[9]; + f19 = MUL_C(COEF_CONST(1.3989068359730781), x[6]); + f20 = MUL_F(FRAC_CONST(-0.8032075314806453), f18); + f21 = MUL_F(FRAC_CONST(-0.2075082269882124), x[9]); + f22 = f19 + f20; + f23 = f21 - f20; + f24 = x[8] + x[7]; + f25 = MUL_C(COEF_CONST(1.4125100802019777), x[8]); + f26 = MUL_F(FRAC_CONST(-0.6715589548470187), f24); + f27 = MUL_F(FRAC_CONST(0.0693921705079402), x[7]); + f28 = f25 + f26; + f29 = f27 - f26; + f30 = x[10] + x[5]; + f31 = MUL_C(COEF_CONST(1.3718313541934939), x[10]); + f32 = MUL_F(FRAC_CONST(-0.5141027441932219), f30); + f33 = MUL_F(FRAC_CONST(0.3436258658070501), x[5]); + f34 = f31 + f32; + f35 = f33 - f32; + f36 = x[12] + x[3]; + f37 = MUL_C(COEF_CONST(1.2784339185752409), x[12]); + f38 = MUL_F(FRAC_CONST(-0.3368898533922200), f36); + f39 = MUL_F(FRAC_CONST(0.6046542117908008), x[3]); + f40 = f37 + f38; + f41 = f39 - f38; + f42 = x[14] + x[1]; + f43 = MUL_C(COEF_CONST(1.1359069844201433), x[14]); + f44 = MUL_F(FRAC_CONST(-0.1467304744553624), f42); + f45 = MUL_F(FRAC_CONST(0.8424460355094185), x[1]); + f46 = f43 + f44; + f47 = f45 - f44; + f48 = f5 - f29; + f49 = f5 + f29; + f50 = f4 - f28; + f51 = f4 + f28; + f52 = f11 - f35; + f53 = f11 + f35; + f54 = f10 - f34; + f55 = f10 + f34; + f56 = f17 - f41; + f57 = f17 + f41; + f58 = f16 - f40; + f59 = f16 + f40; + f60 = f23 - f47; + f61 = f23 + f47; + f62 = f22 - f46; + f63 = f22 + f46; + f64 = f48 + f50; + f65 = MUL_C(COEF_CONST(1.1758756024193588), f48); + f66 = MUL_F(FRAC_CONST(-0.9807852804032304), f64); + f67 = MUL_F(FRAC_CONST(-0.7856949583871021), f50); + f68 = f65 + f66; + f69 = f67 - f66; + f70 = f52 + f54; + f71 = MUL_C(COEF_CONST(1.3870398453221475), f52); + f72 = MUL_F(FRAC_CONST(-0.5555702330196022), f70); + f73 = MUL_F(FRAC_CONST(0.2758993792829431), f54); + f74 = f71 + f72; + f75 = f73 - f72; + f76 = f56 + f58; + f77 = MUL_F(FRAC_CONST(0.7856949583871022), f56); + f78 = MUL_F(FRAC_CONST(0.1950903220161283), f76); + f79 = MUL_C(COEF_CONST(1.1758756024193586), f58); + f80 = f77 + f78; + f81 = f79 - f78; + f82 = f60 + f62; + f83 = MUL_F(FRAC_CONST(-0.2758993792829430), f60); + f84 = MUL_F(FRAC_CONST(0.8314696123025452), f82); + f85 = MUL_C(COEF_CONST(1.3870398453221475), f62); + f86 = f83 + f84; + f87 = f85 - f84; + f88 = f49 - f57; + f89 = f49 + f57; + f90 = f51 - f59; + f91 = f51 + f59; + f92 = f53 - f61; + f93 = f53 + f61; + f94 = f55 - f63; + f95 = f55 + f63; + f96 = f69 - f81; + f97 = f69 + f81; + f98 = f68 - f80; + f99 = f68 + f80; + f100 = f75 - f87; + f101 = f75 + f87; + f102 = f74 - f86; + f103 = f74 + f86; + f104 = f88 + f90; + f105 = MUL_C(COEF_CONST(1.3065629648763766), f88); + f106 = MUL_F(FRAC_CONST(-0.9238795325112866), f104); + f107 = MUL_F(FRAC_CONST(-0.5411961001461967), f90); f108 = f105 + f106; f109 = f107 - f106; - f110 = f90 - f103; - f111 = MUL_F(FRAC_CONST(-0.6666556584777466), f103); - f112 = MUL_F(FRAC_CONST(0.9569403357322089), f110); - f113 = MUL_C(COEF_CONST(1.2472250129866713), f90); - f114 = f112 - f111; + f110 = f92 + f94; + f111 = MUL_F(FRAC_CONST(0.5411961001461969), f92); + f112 = MUL_F(FRAC_CONST(0.3826834323650898), f110); + f113 = MUL_C(COEF_CONST(1.3065629648763766), f94); + f114 = f111 + f112; f115 = f113 - f112; - f116 = f102 + f89; - f117 = MUL_F(FRAC_CONST(-0.4105245275223571), f102); - f118 = MUL_F(FRAC_CONST(0.8819212643483549), f116); - f119 = MUL_C(COEF_CONST(1.3533180011743529), f89); + f116 = f96 + f98; + f117 = MUL_C(COEF_CONST(1.3065629648763766), f96); + f118 = MUL_F(FRAC_CONST(-0.9238795325112866), f116); + f119 = MUL_F(FRAC_CONST(-0.5411961001461967), f98); f120 = f117 + f118; f121 = f119 - f118; - f122 = f87 - f100; - f123 = MUL_F(FRAC_CONST(-0.1386171691990915), f100); - f124 = MUL_F(FRAC_CONST(0.7730104533627370), f122); - f125 = MUL_C(COEF_CONST(1.4074037375263826), f87); - f126 = f124 - f123; + f122 = f100 + f102; + f123 = MUL_F(FRAC_CONST(0.5411961001461969), f100); + f124 = MUL_F(FRAC_CONST(0.3826834323650898), f122); + f125 = MUL_C(COEF_CONST(1.3065629648763766), f102); + f126 = f123 + f124; f127 = f125 - f124; - f128 = f65 - f108; - f129 = f65 + f108; - f130 = f67 - f114; - f131 = f67 + f114; - f132 = f69 - f120; - f133 = f69 + f120; - f134 = f71 - f126; - f135 = f71 + f126; - f136 = f70 - f127; - f137 = f70 + f127; - f138 = f68 - f121; - f139 = f68 + f121; - f140 = f66 - f115; - f141 = f66 + f115; - f142 = f64 - f109; - f143 = f64 + f109; - f144 = f0 + f30; - f145 = MUL_C(COEF_CONST(1.0478631305325901), f0); - f146 = MUL_F(FRAC_CONST(-0.9987954562051724), f144); - f147 = MUL_F(FRAC_CONST(-0.9497277818777548), f30); - f148 = f145 + f146; - f149 = f147 - f146; - f150 = f4 + f26; - f151 = MUL_F(FRAC_CONST(1.2130114330978077), f4); - f152 = MUL_F(FRAC_CONST(-0.9700312531945440), f150); - f153 = MUL_F(FRAC_CONST(-0.7270510732912803), f26); - f154 = f151 + f152; - f155 = f153 - f152; - f156 = f8 + f22; - f157 = MUL_C(COEF_CONST(1.3315443865537255), f8); - f158 = MUL_F(FRAC_CONST(-0.9039892931234433), f156); - f159 = MUL_F(FRAC_CONST(-0.4764341996931612), f22); - f160 = f157 + f158; - f161 = f159 - f158; - f162 = f12 + f18; - f163 = MUL_C(COEF_CONST(1.3989068359730781), f12); - f164 = MUL_F(FRAC_CONST(-0.8032075314806453), f162); - f165 = MUL_F(FRAC_CONST(-0.2075082269882124), f18); + f128 = f89 - f93; + y[0] = f89 + f93; + f130 = f91 - f95; + y[15] = f91 + f95; + f132 = f109 - f115; + y[3] = f109 + f115; + f134 = f108 - f114; + y[12] = f108 + f114; + f136 = f97 - f101; + y[1] = f97 + f101; + f138 = f99 - f103; + y[14] = f99 + f103; + f140 = f121 - f127; + y[2] = f121 + f127; + f142 = f120 - f126; + y[13] = f120 + f126; + f144 = f128 - f130; + f145 = f128 + f130; + y[8] = MUL_F(FRAC_CONST(0.7071067811865474), f144); + y[7] = MUL_F(FRAC_CONST(0.7071067811865474), f145); + f148 = f132 - f134; + f149 = f132 + f134; + y[11] = MUL_F(FRAC_CONST(0.7071067811865474), f148); + y[4] = MUL_F(FRAC_CONST(0.7071067811865474), f149); + f152 = f136 - f138; + f153 = f136 + f138; + y[9] = MUL_F(FRAC_CONST(0.7071067811865474), f152); + y[6] = MUL_F(FRAC_CONST(0.7071067811865474), f153); + f156 = f140 - f142; + f157 = f140 + f142; + y[10] = MUL_F(FRAC_CONST(0.7071067811865474), f156); + y[5] = MUL_F(FRAC_CONST(0.7071067811865474), f157); +} + +void DCT3_32_unscaled(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; + real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; + real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; + real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; + real_t f61, f62, f63, f64, f65, f66, f67, f68, f69, f70; + real_t f71, f72, f73, f74, f75, f76, f77, f78, f79, f80; + real_t f81, f82, f83, f84, f85, f86, f87, f88, f89, f90; + real_t f91, f92, f93, f94, f95, f96, f97, f98, f99, f100; + real_t f101, f102, f103, f104, f105, f106, f107, f108, f109, f110; + real_t f111, f112, f113, f114, f115, f116, f117, f118, f119, f120; + real_t f121, f122, f123, f124, f125, f126, f127, f128, f129, f130; + real_t f131, f132, f133, f134, f135, f136, f137, f138, f139, f140; + real_t f141, f142, f143, f144, f145, f146, f147, f148, f149, f150; + real_t f151, f152, f153, f154, f155, f156, f157, f158, f159, f160; + real_t f161, f162, f163, f164, f165, f166, f167, f168, f169, f170; + real_t f171, f172, f173, f174, f175, f176, f177, f178, f179, f180; + real_t f181, f182, f183, f184, f185, f186, f187, f188, f189, f190; + real_t f191, f192, f193, f194, f195, f196, f197, f198, f199, f200; + real_t f201, f202, f203, f204, f205, f206, f207, f208, f209, f210; + real_t f211, f212, f213, f214, f215, f216, f217, f218, f219, f220; + real_t f221, f222, f223, f224, f225, f226, f227, f228, f229, f230; + real_t f231, f232, f233, f234, f235, f236, f237, f238, f239, f240; + real_t f241, f242, f243, f244, f245, f246, f247, f248, f249, f250; + real_t f251, f252, f253, f254, f255, f256, f257, f258, f259, f260; + real_t f261, f262, f263, f264, f265, f266, f267, f268, f269, f270; + real_t f271, f272; + + f0 = MUL_F(x[16], FRAC_CONST(0.7071067811865476)); + f1 = x[0] - f0; + f2 = x[0] + f0; + f3 = x[8] + x[24]; + f4 = MUL_C(x[8], COEF_CONST(1.3065629648763766)); + f5 = MUL_F(f3, FRAC_CONST((-0.9238795325112866))); + f6 = MUL_F(x[24], FRAC_CONST((-0.5411961001461967))); + f7 = f4 + f5; + f8 = f6 - f5; + f9 = f2 - f8; + f10 = f2 + f8; + f11 = f1 - f7; + f12 = f1 + f7; + f13 = x[4] + x[28]; + f14 = MUL_C(x[4], COEF_CONST(1.1758756024193588)); + f15 = MUL_F(f13, FRAC_CONST((-0.9807852804032304))); + f16 = MUL_F(x[28], FRAC_CONST((-0.7856949583871021))); + f17 = f14 + f15; + f18 = f16 - f15; + f19 = x[12] + x[20]; + f20 = MUL_C(x[12], COEF_CONST(1.3870398453221473)); + f21 = MUL_F(f19, FRAC_CONST((-0.8314696123025455))); + f22 = MUL_F(x[20], FRAC_CONST((-0.2758993792829436))); + f23 = f20 + f21; + f24 = f22 - f21; + f25 = f18 - f24; + f26 = f18 + f24; + f27 = MUL_F(f25, FRAC_CONST(0.7071067811865476)); + f28 = f17 - f23; + f29 = f17 + f23; + f30 = MUL_F(f29, FRAC_CONST(0.7071067811865476)); + f31 = f27 - f30; + f32 = f27 + f30; + f33 = f10 - f26; + f34 = f10 + f26; + f35 = f12 - f32; + f36 = f12 + f32; + f37 = f11 - f31; + f38 = f11 + f31; + f39 = f9 - f28; + f40 = f9 + f28; + f41 = x[2] + x[30]; + f42 = MUL_C(x[2], COEF_CONST(1.0932018670017569)); + f43 = MUL_F(f41, FRAC_CONST((-0.9951847266721969))); + f44 = MUL_F(x[30], FRAC_CONST((-0.8971675863426368))); + f45 = f42 + f43; + f46 = f44 - f43; + f47 = x[6] + x[26]; + f48 = MUL_C(x[6], COEF_CONST(1.2472250129866711)); + f49 = MUL_F(f47, FRAC_CONST((-0.9569403357322089))); + f50 = MUL_F(x[26], FRAC_CONST((-0.6666556584777469))); + f51 = f48 + f49; + f52 = f50 - f49; + f53 = x[10] + x[22]; + f54 = MUL_C(x[10], COEF_CONST(1.3533180011743526)); + f55 = MUL_F(f53, FRAC_CONST((-0.8819212643483551))); + f56 = MUL_F(x[22], FRAC_CONST((-0.4105245275223575))); + f57 = f54 + f55; + f58 = f56 - f55; + f59 = x[14] + x[18]; + f60 = MUL_C(x[14], COEF_CONST(1.4074037375263826)); + f61 = MUL_F(f59, FRAC_CONST((-0.7730104533627369))); + f62 = MUL_F(x[18], FRAC_CONST((-0.1386171691990913))); + f63 = f60 + f61; + f64 = f62 - f61; + f65 = f46 - f64; + f66 = f46 + f64; + f67 = f52 - f58; + f68 = f52 + f58; + f69 = f66 - f68; + f70 = f66 + f68; + f71 = MUL_F(f69, FRAC_CONST(0.7071067811865476)); + f72 = f65 + f67; + f73 = MUL_C(f65, COEF_CONST(1.3065629648763766)); + f74 = MUL_F(f72, FRAC_CONST((-0.9238795325112866))); + f75 = MUL_F(f67, FRAC_CONST((-0.5411961001461967))); + f76 = f73 + f74; + f77 = f75 - f74; + f78 = f45 - f63; + f79 = f45 + f63; + f80 = f51 - f57; + f81 = f51 + f57; + f82 = f79 + f81; + f83 = MUL_C(f79, COEF_CONST(1.3065629648763770)); + f84 = MUL_F(f82, FRAC_CONST((-0.3826834323650904))); + f85 = MUL_F(f81, FRAC_CONST(0.5411961001461961)); + f86 = f83 + f84; + f87 = f85 - f84; + f88 = f78 - f80; + f89 = f78 + f80; + f90 = MUL_F(f89, FRAC_CONST(0.7071067811865476)); + f91 = f77 - f87; + f92 = f77 + f87; + f93 = f71 - f90; + f94 = f71 + f90; + f95 = f76 - f86; + f96 = f76 + f86; + f97 = f34 - f70; + f98 = f34 + f70; + f99 = f36 - f92; + f100 = f36 + f92; + f101 = f38 - f91; + f102 = f38 + f91; + f103 = f40 - f94; + f104 = f40 + f94; + f105 = f39 - f93; + f106 = f39 + f93; + f107 = f37 - f96; + f108 = f37 + f96; + f109 = f35 - f95; + f110 = f35 + f95; + f111 = f33 - f88; + f112 = f33 + f88; + f113 = x[1] + x[31]; + f114 = MUL_C(x[1], COEF_CONST(1.0478631305325901)); + f115 = MUL_F(f113, FRAC_CONST((-0.9987954562051724))); + f116 = MUL_F(x[31], FRAC_CONST((-0.9497277818777548))); + f117 = f114 + f115; + f118 = f116 - f115; + f119 = x[5] + x[27]; + f120 = MUL_C(x[5], COEF_CONST(1.2130114330978077)); + f121 = MUL_F(f119, FRAC_CONST((-0.9700312531945440))); + f122 = MUL_F(x[27], FRAC_CONST((-0.7270510732912803))); + f123 = f120 + f121; + f124 = f122 - f121; + f125 = x[9] + x[23]; + f126 = MUL_C(x[9], COEF_CONST(1.3315443865537255)); + f127 = MUL_F(f125, FRAC_CONST((-0.9039892931234433))); + f128 = MUL_F(x[23], FRAC_CONST((-0.4764341996931612))); + f129 = f126 + f127; + f130 = f128 - f127; + f131 = x[13] + x[19]; + f132 = MUL_C(x[13], COEF_CONST(1.3989068359730781)); + f133 = MUL_F(f131, FRAC_CONST((-0.8032075314806453))); + f134 = MUL_F(x[19], FRAC_CONST((-0.2075082269882124))); + f135 = f132 + f133; + f136 = f134 - f133; + f137 = x[17] + x[15]; + f138 = MUL_C(x[17], COEF_CONST(1.4125100802019777)); + f139 = MUL_F(f137, FRAC_CONST((-0.6715589548470187))); + f140 = MUL_F(x[15], FRAC_CONST(0.0693921705079402)); + f141 = f138 + f139; + f142 = f140 - f139; + f143 = x[21] + x[11]; + f144 = MUL_C(x[21], COEF_CONST(1.3718313541934939)); + f145 = MUL_F(f143, FRAC_CONST((-0.5141027441932219))); + f146 = MUL_F(x[11], FRAC_CONST(0.3436258658070501)); + f147 = f144 + f145; + f148 = f146 - f145; + f149 = x[25] + x[7]; + f150 = MUL_C(x[25], COEF_CONST(1.2784339185752409)); + f151 = MUL_F(f149, FRAC_CONST((-0.3368898533922200))); + f152 = MUL_F(x[7], FRAC_CONST(0.6046542117908008)); + f153 = f150 + f151; + f154 = f152 - f151; + f155 = x[29] + x[3]; + f156 = MUL_C(x[29], COEF_CONST(1.1359069844201433)); + f157 = MUL_F(f155, FRAC_CONST((-0.1467304744553624))); + f158 = MUL_F(x[3], FRAC_CONST(0.8424460355094185)); + f159 = f156 + f157; + f160 = f158 - f157; + f161 = f118 - f142; + f162 = f118 + f142; + f163 = f117 - f141; + f164 = f117 + f141; + f165 = f124 - f148; + f166 = f124 + f148; + f167 = f123 - f147; + f168 = f123 + f147; + f169 = f130 - f154; + f170 = f130 + f154; + f171 = f129 - f153; + f172 = f129 + f153; + f173 = f136 - f160; + f174 = f136 + f160; + f175 = f135 - f159; + f176 = f135 + f159; + f177 = f161 + f163; + f178 = MUL_C(f161, COEF_CONST(1.1758756024193588)); + f179 = MUL_F(f177, FRAC_CONST((-0.9807852804032304))); + f180 = MUL_F(f163, FRAC_CONST((-0.7856949583871021))); + f181 = f178 + f179; + f182 = f180 - f179; + f183 = f165 + f167; + f184 = MUL_C(f165, COEF_CONST(1.3870398453221475)); + f185 = MUL_F(f183, FRAC_CONST((-0.5555702330196022))); + f186 = MUL_F(f167, FRAC_CONST(0.2758993792829431)); + f187 = f184 + f185; + f188 = f186 - f185; + f189 = f169 + f171; + f190 = MUL_F(f169, FRAC_CONST(0.7856949583871022)); + f191 = MUL_F(f189, FRAC_CONST(0.1950903220161283)); + f192 = MUL_C(f171, COEF_CONST(1.1758756024193586)); + f193 = f190 + f191; + f194 = f192 - f191; + f195 = f173 + f175; + f196 = MUL_F(f173, FRAC_CONST((-0.2758993792829430))); + f197 = MUL_F(f195, FRAC_CONST(0.8314696123025452)); + f198 = MUL_C(f175, COEF_CONST(1.3870398453221475)); + f199 = f196 + f197; + f200 = f198 - f197; + f201 = f162 - f170; + f202 = f162 + f170; + f203 = f164 - f172; + f204 = f164 + f172; + f205 = f166 - f174; + f206 = f166 + f174; + f207 = f168 - f176; + f208 = f168 + f176; + f209 = f182 - f194; + f210 = f182 + f194; + f211 = f181 - f193; + f212 = f181 + f193; + f213 = f188 - f200; + f214 = f188 + f200; + f215 = f187 - f199; + f216 = f187 + f199; + f217 = f201 + f203; + f218 = MUL_C(f201, COEF_CONST(1.3065629648763766)); + f219 = MUL_F(f217, FRAC_CONST((-0.9238795325112866))); + f220 = MUL_F(f203, FRAC_CONST((-0.5411961001461967))); + f221 = f218 + f219; + f222 = f220 - f219; + f223 = f205 + f207; + f224 = MUL_F(f205, FRAC_CONST(0.5411961001461969)); + f225 = MUL_F(f223, FRAC_CONST(0.3826834323650898)); + f226 = MUL_C(f207, COEF_CONST(1.3065629648763766)); + f227 = f224 + f225; + f228 = f226 - f225; + f229 = f209 + f211; + f230 = MUL_C(f209, COEF_CONST(1.3065629648763766)); + f231 = MUL_F(f229, FRAC_CONST((-0.9238795325112866))); + f232 = MUL_F(f211, FRAC_CONST((-0.5411961001461967))); + f233 = f230 + f231; + f234 = f232 - f231; + f235 = f213 + f215; + f236 = MUL_F(f213, FRAC_CONST(0.5411961001461969)); + f237 = MUL_F(f235, FRAC_CONST(0.3826834323650898)); + f238 = MUL_C(f215, COEF_CONST(1.3065629648763766)); + f239 = f236 + f237; + f240 = f238 - f237; + f241 = f202 - f206; + f242 = f202 + f206; + f243 = f204 - f208; + f244 = f204 + f208; + f245 = f222 - f228; + f246 = f222 + f228; + f247 = f221 - f227; + f248 = f221 + f227; + f249 = f210 - f214; + f250 = f210 + f214; + f251 = f212 - f216; + f252 = f212 + f216; + f253 = f234 - f240; + f254 = f234 + f240; + f255 = f233 - f239; + f256 = f233 + f239; + f257 = f241 - f243; + f258 = f241 + f243; + f259 = MUL_F(f257, FRAC_CONST(0.7071067811865474)); + f260 = MUL_F(f258, FRAC_CONST(0.7071067811865474)); + f261 = f245 - f247; + f262 = f245 + f247; + f263 = MUL_F(f261, FRAC_CONST(0.7071067811865474)); + f264 = MUL_F(f262, FRAC_CONST(0.7071067811865474)); + f265 = f249 - f251; + f266 = f249 + f251; + f267 = MUL_F(f265, FRAC_CONST(0.7071067811865474)); + f268 = MUL_F(f266, FRAC_CONST(0.7071067811865474)); + f269 = f253 - f255; + f270 = f253 + f255; + f271 = MUL_F(f269, FRAC_CONST(0.7071067811865474)); + f272 = MUL_F(f270, FRAC_CONST(0.7071067811865474)); + y[31] = f98 - f242; + y[0] = f98 + f242; + y[30] = f100 - f250; + y[1] = f100 + f250; + y[29] = f102 - f254; + y[2] = f102 + f254; + y[28] = f104 - f246; + y[3] = f104 + f246; + y[27] = f106 - f264; + y[4] = f106 + f264; + y[26] = f108 - f272; + y[5] = f108 + f272; + y[25] = f110 - f268; + y[6] = f110 + f268; + y[24] = f112 - f260; + y[7] = f112 + f260; + y[23] = f111 - f259; + y[8] = f111 + f259; + y[22] = f109 - f267; + y[9] = f109 + f267; + y[21] = f107 - f271; + y[10] = f107 + f271; + y[20] = f105 - f263; + y[11] = f105 + f263; + y[19] = f103 - f248; + y[12] = f103 + f248; + y[18] = f101 - f256; + y[13] = f101 + f256; + y[17] = f99 - f252; + y[14] = f99 + f252; + y[16] = f97 - f244; + y[15] = f97 + f244; +} + +void DCT2_32_unscaled(real_t *y, real_t *x) +{ + real_t f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10; + real_t f11, f12, f13, f14, f15, f16, f17, f18, f19, f20; + real_t f21, f22, f23, f24, f25, f26, f27, f28, f29, f30; + real_t f31, f32, f33, f34, f35, f36, f37, f38, f39, f40; + real_t f41, f42, f43, f44, f45, f46, f47, f48, f49, f50; + real_t f51, f52, f53, f54, f55, f56, f57, f58, f59, f60; + real_t f63, f64, f65, f66, f69, f70, f71, f72, f73, f74; + real_t f75, f76, f77, f78, f79, f80, f81, f83, f85, f86; + real_t f89, f90, f91, f92, f93, f94, f95, f96, f97, f98; + real_t f99, f100, f101, f102, f103, f104, f105, f106, f107, f108; + real_t f109, f110, f111, f112, f113, f114, f115, f116, f117, f118; + real_t f119, f120, f121, f122, f123, f124, f127, f128, f129, f130; + real_t f133, f134, f135, f136, f139, f140, f141, f142, f145, f146; + real_t f147, f148, f149, f150, f151, f152, f153, f154, f155, f156; + real_t f157, f158, f159, f160, f161, f162, f163, f164, f165, f166; + real_t f167, f168, f169, f170, f171, f172, f173, f174, f175, f176; + real_t f177, f178, f179, f180, f181, f182, f183, f184, f185, f186; + real_t f187, f188, f189, f190, f191, f192, f193, f194, f195, f196; + real_t f197, f198, f199, f200, f201, f202, f203, f204, f205, f206; + real_t f207, f208, f209, f210, f211, f212, f213, f214, f215, f216; + real_t f217, f218, f219, f220, f221, f222, f223, f224, f225, f226; + real_t f227, f228, f229, f230, f231, f232, f233, f234, f235, f236; + real_t f237, f238, f239, f240, f241, f242, f243, f244, f247, f248; + real_t f249, f250, f253, f254, f255, f256, f259, f260, f261, f262; + real_t f265, f266, f267, f268, f271, f272, f273, f274, f277, f278; + real_t f279, f280, f283, f284, f285, f286; + + f0 = x[0] - x[31]; + f1 = x[0] + x[31]; + f2 = x[1] - x[30]; + f3 = x[1] + x[30]; + f4 = x[2] - x[29]; + f5 = x[2] + x[29]; + f6 = x[3] - x[28]; + f7 = x[3] + x[28]; + f8 = x[4] - x[27]; + f9 = x[4] + x[27]; + f10 = x[5] - x[26]; + f11 = x[5] + x[26]; + f12 = x[6] - x[25]; + f13 = x[6] + x[25]; + f14 = x[7] - x[24]; + f15 = x[7] + x[24]; + f16 = x[8] - x[23]; + f17 = x[8] + x[23]; + f18 = x[9] - x[22]; + f19 = x[9] + x[22]; + f20 = x[10] - x[21]; + f21 = x[10] + x[21]; + f22 = x[11] - x[20]; + f23 = x[11] + x[20]; + f24 = x[12] - x[19]; + f25 = x[12] + x[19]; + f26 = x[13] - x[18]; + f27 = x[13] + x[18]; + f28 = x[14] - x[17]; + f29 = x[14] + x[17]; + f30 = x[15] - x[16]; + f31 = x[15] + x[16]; + f32 = f1 - f31; + f33 = f1 + f31; + f34 = f3 - f29; + f35 = f3 + f29; + f36 = f5 - f27; + f37 = f5 + f27; + f38 = f7 - f25; + f39 = f7 + f25; + f40 = f9 - f23; + f41 = f9 + f23; + f42 = f11 - f21; + f43 = f11 + f21; + f44 = f13 - f19; + f45 = f13 + f19; + f46 = f15 - f17; + f47 = f15 + f17; + f48 = f33 - f47; + f49 = f33 + f47; + f50 = f35 - f45; + f51 = f35 + f45; + f52 = f37 - f43; + f53 = f37 + f43; + f54 = f39 - f41; + f55 = f39 + f41; + f56 = f49 - f55; + f57 = f49 + f55; + f58 = f51 - f53; + f59 = f51 + f53; + f60 = f57 - f59; + y[0] = f57 + f59; + y[16] = MUL_F(FRAC_CONST(0.7071067811865476), f60); + f63 = f56 + f58; + f64 = MUL_C(COEF_CONST(1.3065629648763766), f56); + f65 = MUL_F(FRAC_CONST(-0.9238795325112866), f63); + f66 = MUL_F(FRAC_CONST(-0.5411961001461967), f58); + y[24] = f64 + f65; + y[8] = f66 - f65; + f69 = f48 + f54; + f70 = MUL_C(COEF_CONST(1.1758756024193588), f48); + f71 = MUL_F(FRAC_CONST(-0.9807852804032304), f69); + f72 = MUL_F(FRAC_CONST(-0.7856949583871021), f54); + f73 = f70 + f71; + f74 = f72 - f71; + f75 = f50 + f52; + f76 = MUL_C(COEF_CONST(1.3870398453221473), f50); + f77 = MUL_F(FRAC_CONST(-0.8314696123025455), f75); + f78 = MUL_F(FRAC_CONST(-0.2758993792829436), f52); + f79 = f76 + f77; + f80 = f78 - f77; + f81 = f74 - f80; + y[4] = f74 + f80; + f83 = MUL_F(FRAC_CONST(0.7071067811865476), f81); + y[28] = f73 - f79; + f85 = f73 + f79; + f86 = MUL_F(FRAC_CONST(0.7071067811865476), f85); + y[20] = f83 - f86; + y[12] = f83 + f86; + f89 = f34 - f36; + f90 = f34 + f36; + f91 = f38 - f40; + f92 = f38 + f40; + f93 = f42 - f44; + f94 = f42 + f44; + f95 = MUL_F(FRAC_CONST(0.7071067811865476), f92); + f96 = f32 - f95; + f97 = f32 + f95; + f98 = f90 + f94; + f99 = MUL_C(COEF_CONST(1.3065629648763766), f90); + f100 = MUL_F(FRAC_CONST(-0.9238795325112866), f98); + f101 = MUL_F(FRAC_CONST(-0.5411961001461967), f94); + f102 = f99 + f100; + f103 = f101 - f100; + f104 = f97 - f103; + f105 = f97 + f103; + f106 = f96 - f102; + f107 = f96 + f102; + f108 = MUL_F(FRAC_CONST(0.7071067811865476), f91); + f109 = f46 - f108; + f110 = f46 + f108; + f111 = f93 + f89; + f112 = MUL_C(COEF_CONST(1.3065629648763766), f93); + f113 = MUL_F(FRAC_CONST(-0.9238795325112866), f111); + f114 = MUL_F(FRAC_CONST(-0.5411961001461967), f89); + f115 = f112 + f113; + f116 = f114 - f113; + f117 = f110 - f116; + f118 = f110 + f116; + f119 = f109 - f115; + f120 = f109 + f115; + f121 = f118 + f105; + f122 = MUL_F(FRAC_CONST(-0.8971675863426361), f118); + f123 = MUL_F(FRAC_CONST(0.9951847266721968), f121); + f124 = MUL_C(COEF_CONST(1.0932018670017576), f105); + y[2] = f122 + f123; + y[30] = f124 - f123; + f127 = f107 - f120; + f128 = MUL_F(FRAC_CONST(-0.6666556584777466), f120); + f129 = MUL_F(FRAC_CONST(0.9569403357322089), f127); + f130 = MUL_C(COEF_CONST(1.2472250129866713), f107); + y[6] = f129 - f128; + y[26] = f130 - f129; + f133 = f119 + f106; + f134 = MUL_F(FRAC_CONST(-0.4105245275223571), f119); + f135 = MUL_F(FRAC_CONST(0.8819212643483549), f133); + f136 = MUL_C(COEF_CONST(1.3533180011743529), f106); + y[10] = f134 + f135; + y[22] = f136 - f135; + f139 = f104 - f117; + f140 = MUL_F(FRAC_CONST(-0.1386171691990915), f117); + f141 = MUL_F(FRAC_CONST(0.7730104533627370), f139); + f142 = MUL_C(COEF_CONST(1.4074037375263826), f104); + y[14] = f141 - f140; + y[18] = f142 - f141; + f145 = f2 - f4; + f146 = f2 + f4; + f147 = f6 - f8; + f148 = f6 + f8; + f149 = f10 - f12; + f150 = f10 + f12; + f151 = f14 - f16; + f152 = f14 + f16; + f153 = f18 - f20; + f154 = f18 + f20; + f155 = f22 - f24; + f156 = f22 + f24; + f157 = f26 - f28; + f158 = f26 + f28; + f159 = MUL_F(FRAC_CONST(0.7071067811865476), f152); + f160 = f0 - f159; + f161 = f0 + f159; + f162 = f148 + f156; + f163 = MUL_C(COEF_CONST(1.3065629648763766), f148); + f164 = MUL_F(FRAC_CONST(-0.9238795325112866), f162); + f165 = MUL_F(FRAC_CONST(-0.5411961001461967), f156); f166 = f163 + f164; f167 = f165 - f164; - f168 = f16 + f14; - f169 = MUL_C(COEF_CONST(1.4125100802019777), f16); - f170 = MUL_F(FRAC_CONST(-0.6715589548470187), f168); - f171 = MUL_F(FRAC_CONST(0.0693921705079402), f14); - f172 = f169 + f170; - f173 = f171 - f170; - f174 = f20 + f10; - f175 = MUL_C(COEF_CONST(1.3718313541934939), f20); - f176 = MUL_F(FRAC_CONST(-0.5141027441932219), f174); - f177 = MUL_F(FRAC_CONST(0.3436258658070501), f10); - f178 = f175 + f176; - f179 = f177 - f176; - f180 = f24 + f6; - f181 = MUL_C(COEF_CONST(1.2784339185752409), f24); - f182 = MUL_F(FRAC_CONST(-0.3368898533922200), f180); - f183 = MUL_F(FRAC_CONST(0.6046542117908008), f6); - f184 = f181 + f182; - f185 = f183 - f182; - f186 = f28 + f2; - f187 = MUL_C(COEF_CONST(1.1359069844201433), f28); - f188 = MUL_F(FRAC_CONST(-0.1467304744553624), f186); - f189 = MUL_F(FRAC_CONST(0.8424460355094185), f2); - f190 = f187 + f188; - f191 = f189 - f188; - f192 = f149 - f173; - f193 = f149 + f173; - f194 = f148 - f172; - f195 = f148 + f172; - f196 = f155 - f179; - f197 = f155 + f179; - f198 = f154 - f178; - f199 = f154 + f178; - f200 = f161 - f185; - f201 = f161 + f185; - f202 = f160 - f184; - f203 = f160 + f184; - f204 = f167 - f191; - f205 = f167 + f191; - f206 = f166 - f190; - f207 = f166 + f190; - f208 = f192 + f194; - f209 = MUL_C(COEF_CONST(1.1758756024193588), f192); - f210 = MUL_F(FRAC_CONST(-0.9807852804032304), f208); - f211 = MUL_F(FRAC_CONST(-0.7856949583871021), f194); - f212 = f209 + f210; - f213 = f211 - f210; - f214 = f196 + f198; - f215 = MUL_C(COEF_CONST(1.3870398453221475), f196); - f216 = MUL_F(FRAC_CONST(-0.5555702330196022), f214); - f217 = MUL_F(FRAC_CONST(0.2758993792829431), f198); - f218 = f215 + f216; - f219 = f217 - f216; - f220 = f200 + f202; - f221 = MUL_F(FRAC_CONST(0.7856949583871022), f200); - f222 = MUL_F(FRAC_CONST(0.1950903220161283), f220); - f223 = MUL_C(COEF_CONST(1.1758756024193586), f202); - f224 = f221 + f222; - f225 = f223 - f222; - f226 = f204 + f206; - f227 = MUL_F(FRAC_CONST(-0.2758993792829430), f204); - f228 = MUL_F(FRAC_CONST(0.8314696123025452), f226); - f229 = MUL_C(COEF_CONST(1.3870398453221475), f206); - f230 = f227 + f228; - f231 = f229 - f228; - f232 = f193 - f201; - f233 = f193 + f201; - f234 = f195 - f203; - f235 = f195 + f203; - f236 = f197 - f205; - f237 = f197 + f205; - f238 = f199 - f207; - f239 = f199 + f207; - f240 = f213 - f225; - f241 = f213 + f225; - f242 = f212 - f224; - f243 = f212 + f224; - f244 = f219 - f231; - f245 = f219 + f231; - f246 = f218 - f230; - f247 = f218 + f230; - f248 = f232 + f234; - f249 = MUL_C(COEF_CONST(1.3065629648763766), f232); - f250 = MUL_F(FRAC_CONST(-0.9238795325112866), f248); - f251 = MUL_F(FRAC_CONST(-0.5411961001461967), f234); - f252 = f249 + f250; - f253 = f251 - f250; - f254 = f236 + f238; - f255 = MUL_F(FRAC_CONST(0.5411961001461969), f236); - f256 = MUL_F(FRAC_CONST(0.3826834323650898), f254); - f257 = MUL_C(COEF_CONST(1.3065629648763766), f238); - f258 = f255 + f256; - f259 = f257 - f256; - f260 = f240 + f242; - f261 = MUL_C(COEF_CONST(1.3065629648763766), f240); - f262 = MUL_F(FRAC_CONST(-0.9238795325112866), f260); - f263 = MUL_F(FRAC_CONST(-0.5411961001461967), f242); - f264 = f261 + f262; - f265 = f263 - f262; - f266 = f244 + f246; - f267 = MUL_F(FRAC_CONST(0.5411961001461969), f244); - f268 = MUL_F(FRAC_CONST(0.3826834323650898), f266); - f269 = MUL_C(COEF_CONST(1.3065629648763766), f246); - f270 = f267 + f268; - f271 = f269 - f268; - f272 = f233 - f237; - f273 = f233 + f237; - f274 = f235 - f239; - f275 = f235 + f239; - f276 = f253 - f259; - f277 = f253 + f259; - f278 = f252 - f258; - f279 = f252 + f258; - f280 = f241 - f245; - f281 = f241 + f245; - f282 = f243 - f247; - f283 = f243 + f247; - f284 = f265 - f271; - f285 = f265 + f271; - f286 = f264 - f270; - f287 = f264 + f270; - f288 = f272 - f274; - f289 = f272 + f274; - f290 = MUL_F(FRAC_CONST(0.7071067811865474), f288); - f291 = MUL_F(FRAC_CONST(0.7071067811865474), f289); - f292 = f276 - f278; - f293 = f276 + f278; - f294 = MUL_F(FRAC_CONST(0.7071067811865474), f292); - f295 = MUL_F(FRAC_CONST(0.7071067811865474), f293); - f296 = f280 - f282; - f297 = f280 + f282; - f298 = MUL_F(FRAC_CONST(0.7071067811865474), f296); - f299 = MUL_F(FRAC_CONST(0.7071067811865474), f297); - f300 = f284 - f286; - f301 = f284 + f286; - f302 = MUL_F(FRAC_CONST(0.7071067811865474), f300); - f303 = MUL_F(FRAC_CONST(0.7071067811865474), f301); - f304 = f129 - f273; - f305 = f129 + f273; - f306 = f131 - f281; - f307 = f131 + f281; - f308 = f133 - f285; - f309 = f133 + f285; - f310 = f135 - f277; - f311 = f135 + f277; - f312 = f137 - f295; - f313 = f137 + f295; - f314 = f139 - f303; - f315 = f139 + f303; - f316 = f141 - f299; - f317 = f141 + f299; - f318 = f143 - f291; - f319 = f143 + f291; - f320 = f142 - f290; - f321 = f142 + f290; - f322 = f140 - f298; - f323 = f140 + f298; - f324 = f138 - f302; - f325 = f138 + f302; - f326 = f136 - f294; - f327 = f136 + f294; - f328 = f134 - f279; - f329 = f134 + f279; - f330 = f132 - f287; - f331 = f132 + f287; - f332 = f130 - f283; - f333 = f130 + f283; - f334 = f128 - f275; - f335 = f128 + f275; - y[31] = MUL_F(FRAC_CONST(0.5001506360206510), f305); - y[30] = MUL_F(FRAC_CONST(0.5013584524464084), f307); - y[29] = MUL_F(FRAC_CONST(0.5037887256810443), f309); - y[28] = MUL_F(FRAC_CONST(0.5074711720725553), f311); - y[27] = MUL_F(FRAC_CONST(0.5124514794082247), f313); - y[26] = MUL_F(FRAC_CONST(0.5187927131053328), f315); - y[25] = MUL_F(FRAC_CONST(0.5265773151542700), f317); - y[24] = MUL_F(FRAC_CONST(0.5359098169079920), f319); - y[23] = MUL_F(FRAC_CONST(0.5469204379855088), f321); - y[22] = MUL_F(FRAC_CONST(0.5597698129470802), f323); - y[21] = MUL_F(FRAC_CONST(0.5746551840326600), f325); - y[20] = MUL_F(FRAC_CONST(0.5918185358574165), f327); - y[19] = MUL_F(FRAC_CONST(0.6115573478825099), f329); - y[18] = MUL_F(FRAC_CONST(0.6342389366884031), f331); - y[17] = MUL_F(FRAC_CONST(0.6603198078137061), f333); - y[16] = MUL_F(FRAC_CONST(0.6903721282002123), f335); - y[15] = MUL_F(FRAC_CONST(0.7251205223771985), f334); - y[14] = MUL_F(FRAC_CONST(0.7654941649730891), f332); - y[13] = MUL_F(FRAC_CONST(0.8127020908144905), f330); - y[12] = MUL_F(FRAC_CONST(0.8683447152233481), f328); - y[11] = MUL_F(FRAC_CONST(0.9345835970364075), f326); - y[10] = MUL_C(COEF_CONST(1.0144082649970547), f324); - y[9] = MUL_C(COEF_CONST(1.1120716205797176), f322); - y[8] = MUL_C(COEF_CONST(1.2338327379765710), f320); - y[7] = MUL_C(COEF_CONST(1.3892939586328277), f318); - y[6] = MUL_C(COEF_CONST(1.5939722833856311), f316); - y[5] = MUL_C(COEF_CONST(1.8746759800084078), f314); - y[4] = MUL_C(COEF_CONST(2.2820500680051619), f312); - y[3] = MUL_C(COEF_CONST(2.9246284281582162), f310); - y[2] = MUL_C(COEF_CONST(4.0846110781292477), f308); - y[1] = MUL_C(COEF_CONST(6.7967507116736332), f306); - y[0] = MUL_R(REAL_CONST(20.3738781672314530), f304); + f168 = f161 - f167; + f169 = f161 + f167; + f170 = f160 - f166; + f171 = f160 + f166; + f172 = f146 + f158; + f173 = MUL_C(COEF_CONST(1.1758756024193588), f146); + f174 = MUL_F(FRAC_CONST(-0.9807852804032304), f172); + f175 = MUL_F(FRAC_CONST(-0.7856949583871021), f158); + f176 = f173 + f174; + f177 = f175 - f174; + f178 = f150 + f154; + f179 = MUL_C(COEF_CONST(1.3870398453221473), f150); + f180 = MUL_F(FRAC_CONST(-0.8314696123025455), f178); + f181 = MUL_F(FRAC_CONST(-0.2758993792829436), f154); + f182 = f179 + f180; + f183 = f181 - f180; + f184 = f177 - f183; + f185 = f177 + f183; + f186 = MUL_F(FRAC_CONST(0.7071067811865476), f184); + f187 = f176 - f182; + f188 = f176 + f182; + f189 = MUL_F(FRAC_CONST(0.7071067811865476), f188); + f190 = f186 - f189; + f191 = f186 + f189; + f192 = f169 - f185; + f193 = f169 + f185; + f194 = f171 - f191; + f195 = f171 + f191; + f196 = f170 - f190; + f197 = f170 + f190; + f198 = f168 - f187; + f199 = f168 + f187; + f200 = MUL_F(FRAC_CONST(0.7071067811865476), f151); + f201 = f30 - f200; + f202 = f30 + f200; + f203 = f155 + f147; + f204 = MUL_C(COEF_CONST(1.3065629648763766), f155); + f205 = MUL_F(FRAC_CONST(-0.9238795325112866), f203); + f206 = MUL_F(FRAC_CONST(-0.5411961001461967), f147); + f207 = f204 + f205; + f208 = f206 - f205; + f209 = f202 - f208; + f210 = f202 + f208; + f211 = f201 - f207; + f212 = f201 + f207; + f213 = f157 + f145; + f214 = MUL_C(COEF_CONST(1.1758756024193588), f157); + f215 = MUL_F(FRAC_CONST(-0.9807852804032304), f213); + f216 = MUL_F(FRAC_CONST(-0.7856949583871021), f145); + f217 = f214 + f215; + f218 = f216 - f215; + f219 = f153 + f149; + f220 = MUL_C(COEF_CONST(1.3870398453221473), f153); + f221 = MUL_F(FRAC_CONST(-0.8314696123025455), f219); + f222 = MUL_F(FRAC_CONST(-0.2758993792829436), f149); + f223 = f220 + f221; + f224 = f222 - f221; + f225 = f218 - f224; + f226 = f218 + f224; + f227 = MUL_F(FRAC_CONST(0.7071067811865476), f225); + f228 = f217 - f223; + f229 = f217 + f223; + f230 = MUL_F(FRAC_CONST(0.7071067811865476), f229); + f231 = f227 - f230; + f232 = f227 + f230; + f233 = f210 - f226; + f234 = f210 + f226; + f235 = f212 - f232; + f236 = f212 + f232; + f237 = f211 - f231; + f238 = f211 + f231; + f239 = f209 - f228; + f240 = f209 + f228; + f241 = f234 + f193; + f242 = MUL_F(FRAC_CONST(-0.9497277818777543), f234); + f243 = MUL_F(FRAC_CONST(0.9987954562051724), f241); + f244 = MUL_C(COEF_CONST(1.0478631305325905), f193); + y[1] = f242 + f243; + y[31] = f244 - f243; + f247 = f195 - f236; + f248 = MUL_F(FRAC_CONST(-0.8424460355094192), f236); + f249 = MUL_F(FRAC_CONST(0.9891765099647810), f247); + f250 = MUL_C(COEF_CONST(1.1359069844201428), f195); + y[3] = f249 - f248; + y[29] = f250 - f249; + f253 = f238 + f197; + f254 = MUL_F(FRAC_CONST(-0.7270510732912801), f238); + f255 = MUL_F(FRAC_CONST(0.9700312531945440), f253); + f256 = MUL_C(COEF_CONST(1.2130114330978079), f197); + y[5] = f254 + f255; + y[27] = f256 - f255; + f259 = f199 - f240; + f260 = MUL_F(FRAC_CONST(-0.6046542117908007), f240); + f261 = MUL_F(FRAC_CONST(0.9415440651830208), f259); + f262 = MUL_C(COEF_CONST(1.2784339185752409), f199); + y[7] = f261 - f260; + y[25] = f262 - f261; + f265 = f239 + f198; + f266 = MUL_F(FRAC_CONST(-0.4764341996931611), f239); + f267 = MUL_F(FRAC_CONST(0.9039892931234433), f265); + f268 = MUL_C(COEF_CONST(1.3315443865537255), f198); + y[9] = f266 + f267; + y[23] = f268 - f267; + f271 = f196 - f237; + f272 = MUL_F(FRAC_CONST(-0.3436258658070505), f237); + f273 = MUL_F(FRAC_CONST(0.8577286100002721), f271); + f274 = MUL_C(COEF_CONST(1.3718313541934939), f196); + y[11] = f273 - f272; + y[21] = f274 - f273; + f277 = f235 + f194; + f278 = MUL_F(FRAC_CONST(-0.2075082269882114), f235); + f279 = MUL_F(FRAC_CONST(0.8032075314806448), f277); + f280 = MUL_C(COEF_CONST(1.3989068359730783), f194); + y[13] = f278 + f279; + y[19] = f280 - f279; + f283 = f192 - f233; + f284 = MUL_F(FRAC_CONST(-0.0693921705079408), f233); + f285 = MUL_F(FRAC_CONST(0.7409511253549591), f283); + f286 = MUL_C(COEF_CONST(1.4125100802019774), f192); + y[15] = f285 - f284; + y[17] = f286 - f285; +} + +#else + + +#define n 32 +#define log2n 5 + +// w_array_real[i] = cos(2*M_PI*i/32) +static const real_t w_array_real[] = { + FRAC_CONST(1.000000000000000), FRAC_CONST(0.980785279337272), + FRAC_CONST(0.923879528329380), FRAC_CONST(0.831469603195765), + FRAC_CONST(0.707106765732237), FRAC_CONST(0.555570210304169), + FRAC_CONST(0.382683402077046), FRAC_CONST(0.195090284503576), + FRAC_CONST(0.000000000000000), FRAC_CONST(-0.195090370246552), + FRAC_CONST(-0.382683482845162), FRAC_CONST(-0.555570282993553), + FRAC_CONST(-0.707106827549476), FRAC_CONST(-0.831469651765257), + FRAC_CONST(-0.923879561784627), FRAC_CONST(-0.980785296392607) +}; + +// w_array_imag[i] = sin(-2*M_PI*i/32) +static const real_t w_array_imag[] = { + FRAC_CONST(0.000000000000000), FRAC_CONST(-0.195090327375064), + FRAC_CONST(-0.382683442461104), FRAC_CONST(-0.555570246648862), + FRAC_CONST(-0.707106796640858), FRAC_CONST(-0.831469627480512), + FRAC_CONST(-0.923879545057005), FRAC_CONST(-0.980785287864940), + FRAC_CONST(-1.000000000000000), FRAC_CONST(-0.980785270809601), + FRAC_CONST(-0.923879511601754), FRAC_CONST(-0.831469578911016), + FRAC_CONST(-0.707106734823616), FRAC_CONST(-0.555570173959476), + FRAC_CONST(-0.382683361692986), FRAC_CONST(-0.195090241632088) +}; + +// FFT decimation in frequency +// 4*16*2+16=128+16=144 multiplications +// 6*16*2+10*8+4*16*2=192+80+128=400 additions +static void fft_dif(real_t * Real, real_t * Imag) +{ + real_t w_real, w_imag; // For faster access + real_t point1_real, point1_imag, point2_real, point2_imag; // For faster access + uint32_t j, i, i2, w_index; // Counters + + // First 2 stages of 32 point FFT decimation in frequency + // 4*16*2=64*2=128 multiplications + // 6*16*2=96*2=192 additions + // Stage 1 of 32 point FFT decimation in frequency + for (i = 0; i < 16; i++) + { + point1_real = Real[i]; + point1_imag = Imag[i]; + i2 = i+16; + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + w_real = w_array_real[i]; + w_imag = w_array_imag[i]; + + // temp1 = x[i] - x[i2] + point1_real -= point2_real; + point1_imag -= point2_imag; + + // x[i1] = x[i] + x[i2] + Real[i] += point2_real; + Imag[i] += point2_imag; + + // x[i2] = (x[i] - x[i2]) * w + Real[i2] = (MUL_F(point1_real,w_real) - MUL_F(point1_imag,w_imag)); + Imag[i2] = (MUL_F(point1_real,w_imag) + MUL_F(point1_imag,w_real)); + } + // Stage 2 of 32 point FFT decimation in frequency + for (j = 0, w_index = 0; j < 8; j++, w_index += 2) + { + w_real = w_array_real[w_index]; + w_imag = w_array_imag[w_index]; + + i = j; + point1_real = Real[i]; + point1_imag = Imag[i]; + i2 = i+8; + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // temp1 = x[i] - x[i2] + point1_real -= point2_real; + point1_imag -= point2_imag; + + // x[i1] = x[i] + x[i2] + Real[i] += point2_real; + Imag[i] += point2_imag; + + // x[i2] = (x[i] - x[i2]) * w + Real[i2] = (MUL_F(point1_real,w_real) - MUL_F(point1_imag,w_imag)); + Imag[i2] = (MUL_F(point1_real,w_imag) + MUL_F(point1_imag,w_real)); + + i = j+16; + point1_real = Real[i]; + point1_imag = Imag[i]; + i2 = i+8; + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // temp1 = x[i] - x[i2] + point1_real -= point2_real; + point1_imag -= point2_imag; + + // x[i1] = x[i] + x[i2] + Real[i] += point2_real; + Imag[i] += point2_imag; + + // x[i2] = (x[i] - x[i2]) * w + Real[i2] = (MUL_F(point1_real,w_real) - MUL_F(point1_imag,w_imag)); + Imag[i2] = (MUL_F(point1_real,w_imag) + MUL_F(point1_imag,w_real)); + } + + // Stage 3 of 32 point FFT decimation in frequency + // 2*4*2=16 multiplications + // 4*4*2+6*4*2=10*8=80 additions + for (i = 0; i < n; i += 8) + { + i2 = i+4; + point1_real = Real[i]; + point1_imag = Imag[i]; + + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // out[i1] = point1 + point2 + Real[i] += point2_real; + Imag[i] += point2_imag; + + // out[i2] = point1 - point2 + Real[i2] = point1_real - point2_real; + Imag[i2] = point1_imag - point2_imag; + } + w_real = w_array_real[4]; // = sqrt(2)/2 + // w_imag = -w_real; // = w_array_imag[4]; // = -sqrt(2)/2 + for (i = 1; i < n; i += 8) + { + i2 = i+4; + point1_real = Real[i]; + point1_imag = Imag[i]; + + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // temp1 = x[i] - x[i2] + point1_real -= point2_real; + point1_imag -= point2_imag; + + // x[i1] = x[i] + x[i2] + Real[i] += point2_real; + Imag[i] += point2_imag; + + // x[i2] = (x[i] - x[i2]) * w + Real[i2] = MUL_F(point1_real+point1_imag, w_real); + Imag[i2] = MUL_F(point1_imag-point1_real, w_real); + } + for (i = 2; i < n; i += 8) + { + i2 = i+4; + point1_real = Real[i]; + point1_imag = Imag[i]; + + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // x[i] = x[i] + x[i2] + Real[i] += point2_real; + Imag[i] += point2_imag; + + // x[i2] = (x[i] - x[i2]) * (-i) + Real[i2] = point1_imag - point2_imag; + Imag[i2] = point2_real - point1_real; + } + w_real = w_array_real[12]; // = -sqrt(2)/2 + // w_imag = w_real; // = w_array_imag[12]; // = -sqrt(2)/2 + for (i = 3; i < n; i += 8) + { + i2 = i+4; + point1_real = Real[i]; + point1_imag = Imag[i]; + + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // temp1 = x[i] - x[i2] + point1_real -= point2_real; + point1_imag -= point2_imag; + + // x[i1] = x[i] + x[i2] + Real[i] += point2_real; + Imag[i] += point2_imag; + + // x[i2] = (x[i] - x[i2]) * w + Real[i2] = MUL_F(point1_real-point1_imag, w_real); + Imag[i2] = MUL_F(point1_real+point1_imag, w_real); + } + + + // Stage 4 of 32 point FFT decimation in frequency (no multiplications) + // 16*4=64 additions + for (i = 0; i < n; i += 4) + { + i2 = i+2; + point1_real = Real[i]; + point1_imag = Imag[i]; + + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // x[i1] = x[i] + x[i2] + Real[i] += point2_real; + Imag[i] += point2_imag; + + // x[i2] = x[i] - x[i2] + Real[i2] = point1_real - point2_real; + Imag[i2] = point1_imag - point2_imag; + } + for (i = 1; i < n; i += 4) + { + i2 = i+2; + point1_real = Real[i]; + point1_imag = Imag[i]; + + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // x[i] = x[i] + x[i2] + Real[i] += point2_real; + Imag[i] += point2_imag; + + // x[i2] = (x[i] - x[i2]) * (-i) + Real[i2] = point1_imag - point2_imag; + Imag[i2] = point2_real - point1_real; + } + + // Stage 5 of 32 point FFT decimation in frequency (no multiplications) + // 16*4=64 additions + for (i = 0; i < n; i += 2) + { + i2 = i+1; + point1_real = Real[i]; + point1_imag = Imag[i]; + + point2_real = Real[i2]; + point2_imag = Imag[i2]; + + // out[i1] = point1 + point2 + Real[i] += point2_real; + Imag[i] += point2_imag; + + // out[i2] = point1 - point2 + Real[i2] = point1_real - point2_real; + Imag[i2] = point1_imag - point2_imag; + } + +#ifdef REORDER_IN_FFT + FFTReorder(Real, Imag); +#endif // #ifdef REORDER_IN_FFT +} +#undef n +#undef log2n + +static const real_t dct4_64_tab[] = { + COEF_CONST(0.999924719333649), COEF_CONST(0.998118102550507), + COEF_CONST(0.993906974792480), COEF_CONST(0.987301409244537), + COEF_CONST(0.978317379951477), COEF_CONST(0.966976463794708), + COEF_CONST(0.953306019306183), COEF_CONST(0.937339007854462), + COEF_CONST(0.919113874435425), COEF_CONST(0.898674488067627), + COEF_CONST(0.876070082187653), COEF_CONST(0.851355195045471), + COEF_CONST(0.824589252471924), COEF_CONST(0.795836925506592), + COEF_CONST(0.765167236328125), COEF_CONST(0.732654273509979), + COEF_CONST(0.698376238346100), COEF_CONST(0.662415742874146), + COEF_CONST(0.624859452247620), COEF_CONST(0.585797846317291), + COEF_CONST(0.545324981212616), COEF_CONST(0.503538429737091), + COEF_CONST(0.460538715124130), COEF_CONST(0.416429549455643), + COEF_CONST(0.371317148208618), COEF_CONST(0.325310230255127), + COEF_CONST(0.278519600629807), COEF_CONST(0.231058135628700), + COEF_CONST(0.183039888739586), COEF_CONST(0.134580686688423), + COEF_CONST(0.085797272622585), COEF_CONST(0.036807164549828), + COEF_CONST(-1.012196302413940), COEF_CONST(-1.059438824653626), + COEF_CONST(-1.104129195213318), COEF_CONST(-1.146159529685974), + COEF_CONST(-1.185428738594055), COEF_CONST(-1.221842169761658), + COEF_CONST(-1.255311965942383), COEF_CONST(-1.285757660865784), + COEF_CONST(-1.313105940818787), COEF_CONST(-1.337290763854981), + COEF_CONST(-1.358253836631775), COEF_CONST(-1.375944852828980), + COEF_CONST(-1.390321016311646), COEF_CONST(-1.401347875595093), + COEF_CONST(-1.408998727798462), COEF_CONST(-1.413255214691162), + COEF_CONST(-1.414107084274292), COEF_CONST(-1.411552190780640), + COEF_CONST(-1.405596733093262), COEF_CONST(-1.396255016326904), + COEF_CONST(-1.383549690246582), COEF_CONST(-1.367511272430420), + COEF_CONST(-1.348178386688232), COEF_CONST(-1.325597524642944), + COEF_CONST(-1.299823284149170), COEF_CONST(-1.270917654037476), + COEF_CONST(-1.238950133323669), COEF_CONST(-1.203998088836670), + COEF_CONST(-1.166145324707031), COEF_CONST(-1.125483393669128), + COEF_CONST(-1.082109928131104), COEF_CONST(-1.036129593849182), + COEF_CONST(-0.987653195858002), COEF_CONST(-0.936797380447388), + COEF_CONST(-0.883684754371643), COEF_CONST(-0.828443288803101), + COEF_CONST(-0.771206021308899), COEF_CONST(-0.712110757827759), + COEF_CONST(-0.651300072669983), COEF_CONST(-0.588920354843140), + COEF_CONST(-0.525121808052063), COEF_CONST(-0.460058242082596), + COEF_CONST(-0.393886327743530), COEF_CONST(-0.326765477657318), + COEF_CONST(-0.258857429027557), COEF_CONST(-0.190325915813446), + COEF_CONST(-0.121335685253143), COEF_CONST(-0.052053272724152), + COEF_CONST(0.017354607582092), COEF_CONST(0.086720645427704), + COEF_CONST(0.155877828598022), COEF_CONST(0.224659323692322), + COEF_CONST(0.292899727821350), COEF_CONST(0.360434412956238), + COEF_CONST(0.427100926637650), COEF_CONST(0.492738455533981), + COEF_CONST(0.557188928127289), COEF_CONST(0.620297133922577), + COEF_CONST(0.681910991668701), COEF_CONST(0.741881847381592), + COEF_CONST(0.800065577030182), COEF_CONST(0.856321990489960), + COEF_CONST(0.910515367984772), COEF_CONST(0.962515234947205), + COEF_CONST(1.000000000000000), COEF_CONST(0.998795449733734), + COEF_CONST(0.995184719562531), COEF_CONST(0.989176511764526), + COEF_CONST(0.980785250663757), COEF_CONST(0.970031261444092), + COEF_CONST(0.956940352916718), COEF_CONST(0.941544055938721), + COEF_CONST(0.923879504203796), COEF_CONST(0.903989315032959), + COEF_CONST(0.881921231746674), COEF_CONST(0.857728600502014), + COEF_CONST(0.831469595432281), COEF_CONST(0.803207516670227), + COEF_CONST(0.773010432720184), COEF_CONST(0.740951120853424), + COEF_CONST(0.707106769084930), COEF_CONST(0.671558916568756), + COEF_CONST(0.634393274784088), COEF_CONST(0.595699310302734), + COEF_CONST(0.555570185184479), COEF_CONST(0.514102697372437), + COEF_CONST(0.471396654844284), COEF_CONST(0.427555114030838), + COEF_CONST(0.382683426141739), COEF_CONST(0.336889833211899), + COEF_CONST(0.290284633636475), COEF_CONST(0.242980122566223), + COEF_CONST(0.195090234279633), COEF_CONST(0.146730497479439), + COEF_CONST(0.098017133772373), COEF_CONST(0.049067649990320), + COEF_CONST(-1.000000000000000), COEF_CONST(-1.047863125801086), + COEF_CONST(-1.093201875686646), COEF_CONST(-1.135906934738159), + COEF_CONST(-1.175875544548035), COEF_CONST(-1.213011503219605), + COEF_CONST(-1.247225046157837), COEF_CONST(-1.278433918952942), + COEF_CONST(-1.306562900543213), COEF_CONST(-1.331544399261475), + COEF_CONST(-1.353317975997925), COEF_CONST(-1.371831417083740), + COEF_CONST(-1.387039899826050), COEF_CONST(-1.398906826972961), + COEF_CONST(-1.407403707504273), COEF_CONST(-1.412510156631470), + COEF_CONST(0), COEF_CONST(-1.412510156631470), + COEF_CONST(-1.407403707504273), COEF_CONST(-1.398906826972961), + COEF_CONST(-1.387039899826050), COEF_CONST(-1.371831417083740), + COEF_CONST(-1.353317975997925), COEF_CONST(-1.331544399261475), + COEF_CONST(-1.306562900543213), COEF_CONST(-1.278433918952942), + COEF_CONST(-1.247225046157837), COEF_CONST(-1.213011384010315), + COEF_CONST(-1.175875544548035), COEF_CONST(-1.135907053947449), + COEF_CONST(-1.093201875686646), COEF_CONST(-1.047863125801086), + COEF_CONST(-1.000000000000000), COEF_CONST(-0.949727773666382), + COEF_CONST(-0.897167563438416), COEF_CONST(-0.842446029186249), + COEF_CONST(-0.785694956779480), COEF_CONST(-0.727051079273224), + COEF_CONST(-0.666655659675598), COEF_CONST(-0.604654192924500), + COEF_CONST(-0.541196048259735), COEF_CONST(-0.476434230804443), + COEF_CONST(-0.410524487495422), COEF_CONST(-0.343625843524933), + COEF_CONST(-0.275899350643158), COEF_CONST(-0.207508206367493), + COEF_CONST(-0.138617098331451), COEF_CONST(-0.069392144680023), + COEF_CONST(0), COEF_CONST(0.069392263889313), + COEF_CONST(0.138617157936096), COEF_CONST(0.207508206367493), + COEF_CONST(0.275899469852448), COEF_CONST(0.343625962734222), + COEF_CONST(0.410524636507034), COEF_CONST(0.476434201002121), + COEF_CONST(0.541196107864380), COEF_CONST(0.604654192924500), + COEF_CONST(0.666655719280243), COEF_CONST(0.727051138877869), + COEF_CONST(0.785695075988770), COEF_CONST(0.842446029186249), + COEF_CONST(0.897167563438416), COEF_CONST(0.949727773666382) +}; + +/* size 64 only! */ +void dct4_kernel(real_t * in_real, real_t * in_imag, real_t * out_real, real_t * out_imag) +{ + // Tables with bit reverse values for 5 bits, bit reverse of i at i-th position + const uint8_t bit_rev_tab[32] = { 0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23,15,31 }; + uint32_t i, i_rev; + + /* Step 2: modulate */ + // 3*32=96 multiplications + // 3*32=96 additions + for (i = 0; i < 32; i++) + { + real_t x_re, x_im, tmp; + x_re = in_real[i]; + x_im = in_imag[i]; + tmp = MUL_C(x_re + x_im, dct4_64_tab[i]); + in_real[i] = MUL_C(x_im, dct4_64_tab[i + 64]) + tmp; + in_imag[i] = MUL_C(x_re, dct4_64_tab[i + 32]) + tmp; + } + + /* Step 3: FFT, but with output in bit reverse order */ + fft_dif(in_real, in_imag); + + /* Step 4: modulate + bitreverse reordering */ + // 3*31+2=95 multiplications + // 3*31+2=95 additions + for (i = 0; i < 16; i++) + { + real_t x_re, x_im, tmp; + i_rev = bit_rev_tab[i]; + x_re = in_real[i_rev]; + x_im = in_imag[i_rev]; + + tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]); + out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp; + out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4*32]) + tmp; + } + // i = 16, i_rev = 1 = rev(16); + out_imag[16] = MUL_C(in_imag[1] - in_real[1], dct4_64_tab[16 + 3*32]); + out_real[16] = MUL_C(in_real[1] + in_imag[1], dct4_64_tab[16 + 3*32]); + for (i = 17; i < 32; i++) + { + real_t x_re, x_im, tmp; + i_rev = bit_rev_tab[i]; + x_re = in_real[i_rev]; + x_im = in_imag[i_rev]; + tmp = MUL_C(x_re + x_im, dct4_64_tab[i + 3*32]); + out_real[i] = MUL_C(x_im, dct4_64_tab[i + 5*32]) + tmp; + out_imag[i] = MUL_C(x_re, dct4_64_tab[i + 4*32]) + tmp; + } + } #endif diff --git a/src/libfaad/sbr_dct.h b/src/libfaad/sbr_dct.h index 6293486c7..ce44fd7ef 100644 --- a/src/libfaad/sbr_dct.h +++ b/src/libfaad/sbr_dct.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_dct.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_dct.h,v 1.19 2007/11/01 12:33:34 menno Exp $ **/ #ifndef __SBR_DCT_H__ diff --git a/src/libfaad/sbr_dec.c b/src/libfaad/sbr_dec.c index 24c1f5031..f87d0106c 100644 --- a/src/libfaad/sbr_dec.c +++ b/src/libfaad/sbr_dec.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_dec.c,v 1.9 2006/06/17 20:43:57 dgp85 Exp $ +** $Id: sbr_dec.c,v 1.43 2007/11/01 12:33:34 menno Exp $ **/ @@ -176,6 +179,72 @@ void sbrDecodeEnd(sbr_info *sbr) } } +void sbrReset(sbr_info *sbr) +{ + uint8_t j; + if (sbr->qmfa[0] != NULL) + memset(sbr->qmfa[0]->x, 0, 2 * sbr->qmfa[0]->channels * 10 * sizeof(real_t)); + if (sbr->qmfa[1] != NULL) + memset(sbr->qmfa[1]->x, 0, 2 * sbr->qmfa[1]->channels * 10 * sizeof(real_t)); + if (sbr->qmfs[0] != NULL) + memset(sbr->qmfs[0]->v, 0, 2 * sbr->qmfs[0]->channels * 20 * sizeof(real_t)); + if (sbr->qmfs[1] != NULL) + memset(sbr->qmfs[1]->v, 0, 2 * sbr->qmfs[1]->channels * 20 * sizeof(real_t)); + + for (j = 0; j < 5; j++) + { + if (sbr->G_temp_prev[0][j] != NULL) + memset(sbr->G_temp_prev[0][j], 0, 64*sizeof(real_t)); + if (sbr->G_temp_prev[1][j] != NULL) + memset(sbr->G_temp_prev[1][j], 0, 64*sizeof(real_t)); + if (sbr->Q_temp_prev[0][j] != NULL) + memset(sbr->Q_temp_prev[0][j], 0, 64*sizeof(real_t)); + if (sbr->Q_temp_prev[1][j] != NULL) + memset(sbr->Q_temp_prev[1][j], 0, 64*sizeof(real_t)); + } + + memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); + memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); + + sbr->GQ_ringbuf_index[0] = 0; + sbr->GQ_ringbuf_index[1] = 0; + sbr->header_count = 0; + sbr->Reset = 1; + + sbr->L_E_prev[0] = 0; + sbr->L_E_prev[1] = 0; + sbr->bs_freq_scale = 2; + sbr->bs_alter_scale = 1; + sbr->bs_noise_bands = 2; + sbr->bs_limiter_bands = 2; + sbr->bs_limiter_gains = 2; + sbr->bs_interpol_freq = 1; + sbr->bs_smoothing_mode = 1; + sbr->bs_start_freq = 5; + sbr->bs_amp_res = 1; + sbr->bs_samplerate_mode = 1; + sbr->prevEnvIsShort[0] = -1; + sbr->prevEnvIsShort[1] = -1; + sbr->bsco = 0; + sbr->bsco_prev = 0; + sbr->M_prev = 0; + sbr->bs_start_freq_prev = -1; + + sbr->f_prev[0] = 0; + sbr->f_prev[1] = 0; + for (j = 0; j < MAX_M; j++) + { + sbr->E_prev[0][j] = 0; + sbr->Q_prev[0][j] = 0; + sbr->E_prev[1][j] = 0; + sbr->Q_prev[1][j] = 0; + sbr->bs_add_harmonic_prev[0][j] = 0; + sbr->bs_add_harmonic_prev[1][j] = 0; + } + sbr->bs_add_harmonic_flag_prev[0] = 0; + sbr->bs_add_harmonic_flag_prev[1] = 0; +} + static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) { uint8_t i; @@ -226,11 +295,12 @@ static void sbr_save_matrix(sbr_info *sbr, uint8_t ch) } } -static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], - uint8_t ch, uint8_t dont_process, - const uint8_t downSampledSBR) +static uint8_t sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], + uint8_t ch, uint8_t dont_process, + const uint8_t downSampledSBR) { int16_t k, l; + uint8_t ret = 0; #ifdef SBR_LOW_POWER ALIGN real_t deg[64]; @@ -278,7 +348,7 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_ ,ch); #endif -#ifdef SBR_LOW_POWER +#if 0 //def SBR_LOW_POWER for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) { for (k = 0; k < sbr->kx; k++) @@ -290,12 +360,16 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_ #if 1 /* hf adjustment */ - hf_adjustment(sbr, sbr->Xsbr[ch] + ret = hf_adjustment(sbr, sbr->Xsbr[ch] #ifdef SBR_LOW_POWER ,deg #endif ,ch); #endif + if (ret > 0) + { + dont_process = 1; + } } if ((sbr->just_seeked != 0) || dont_process) @@ -367,6 +441,8 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_ #endif } } + + return ret; } uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, @@ -400,7 +476,7 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_cha sbr->just_seeked = 0; } - sbr_process_channel(sbr, left_chan, X, 0, dont_process, downSampledSBR); + sbr->ret += sbr_process_channel(sbr, left_chan, X, 0, dont_process, downSampledSBR); /* subband synthesis */ if (downSampledSBR) { @@ -409,7 +485,7 @@ uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_cha sbr_qmf_synthesis_64(sbr, sbr->qmfs[0], X, left_chan); } - sbr_process_channel(sbr, right_chan, X, 1, dont_process, downSampledSBR); + sbr->ret += sbr_process_channel(sbr, right_chan, X, 1, dont_process, downSampledSBR); /* subband synthesis */ if (downSampledSBR) { @@ -483,7 +559,7 @@ uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, sbr->just_seeked = 0; } - sbr_process_channel(sbr, channel, X, 0, dont_process, downSampledSBR); + sbr->ret += sbr_process_channel(sbr, channel, X, 0, dont_process, downSampledSBR); /* subband synthesis */ if (downSampledSBR) { @@ -526,8 +602,8 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ uint8_t l, k; uint8_t dont_process = 0; uint8_t ret = 0; - ALIGN qmf_t X_left[38][64] = {{{0}}}; - ALIGN qmf_t X_right[38][64] = {{{0}}}; /* must set this to 0 */ + ALIGN qmf_t X_left[38][64] = {{0}}; + ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */ if (sbr == NULL) return 20; @@ -558,7 +634,7 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64); } - sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR); + sbr->ret += sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR); /* copy some extra data for PS */ for (l = 32; l < 38; l++) @@ -574,7 +650,7 @@ uint8_t sbrDecodeSingleFramePS(sbr_info *sbr, real_t *left_channel, real_t *righ #ifdef DRM_PS if (sbr->Is_DRM_SBR) { - drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), sbr->sample_rate, X_left, X_right); + drm_ps_decode(sbr->drm_ps, (sbr->ret > 0), X_left, X_right); } else { #endif #ifdef PS_DEC diff --git a/src/libfaad/sbr_dec.h b/src/libfaad/sbr_dec.h index 5efd5c5e0..40c1d5388 100644 --- a/src/libfaad/sbr_dec.h +++ b/src/libfaad/sbr_dec.h @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_dec.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_dec.h,v 1.39 2007/11/01 12:33:34 menno Exp $ **/ #ifndef __SBR_DEC_H__ @@ -183,6 +186,7 @@ typedef struct #endif #if (defined(PS_DEC) || defined(DRM_PS)) uint8_t ps_used; + uint8_t psResetFlag; #endif /* to get it compiling */ @@ -231,6 +235,7 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, #endif ); void sbrDecodeEnd(sbr_info *sbr); +void sbrReset(sbr_info *sbr); uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, const uint8_t just_seeked, const uint8_t downSampledSBR); diff --git a/src/libfaad/sbr_e_nf.c b/src/libfaad/sbr_e_nf.c index 2d2bf4f85..14ba1e4a5 100644 --- a/src/libfaad/sbr_e_nf.c +++ b/src/libfaad/sbr_e_nf.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_e_nf.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_e_nf.c,v 1.21 2007/11/01 12:33:35 menno Exp $ **/ #include "common.h" diff --git a/src/libfaad/sbr_e_nf.h b/src/libfaad/sbr_e_nf.h index 48874c125..59017a906 100644 --- a/src/libfaad/sbr_e_nf.h +++ b/src/libfaad/sbr_e_nf.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_e_nf.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_e_nf.h,v 1.18 2007/11/01 12:33:35 menno Exp $ **/ #ifndef __SBR_E_NF_H__ diff --git a/src/libfaad/sbr_fbt.c b/src/libfaad/sbr_fbt.c index 511235863..5919c7b56 100644 --- a/src/libfaad/sbr_fbt.c +++ b/src/libfaad/sbr_fbt.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_fbt.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_fbt.c,v 1.21 2007/11/01 12:33:35 menno Exp $ **/ /* Calculate frequency band tables */ diff --git a/src/libfaad/sbr_fbt.h b/src/libfaad/sbr_fbt.h index 26c580efe..d24a25e27 100644 --- a/src/libfaad/sbr_fbt.h +++ b/src/libfaad/sbr_fbt.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_fbt.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_fbt.h,v 1.18 2007/11/01 12:33:35 menno Exp $ **/ #ifndef __SBR_FBT_H__ diff --git a/src/libfaad/sbr_hfadj.c b/src/libfaad/sbr_hfadj.c index 081f731e9..efac06502 100644 --- a/src/libfaad/sbr_hfadj.c +++ b/src/libfaad/sbr_hfadj.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_hfadj.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_hfadj.c,v 1.22 2007/11/01 12:33:35 menno Exp $ **/ /* High Frequency adjustment */ @@ -39,8 +42,8 @@ /* static function declarations */ -static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, - qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch); +static uint8_t estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, + qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch); static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); #ifdef SBR_LOW_POWER static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); @@ -49,13 +52,14 @@ static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch); -void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] +uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] #ifdef SBR_LOW_POWER - ,real_t *deg /* aliasing degree */ + ,real_t *deg /* aliasing degree */ #endif - ,uint8_t ch) + ,uint8_t ch) { ALIGN sbr_hfadj_info adj = {{{0}}}; + uint8_t ret = 0; if (sbr->bs_frame_class[ch] == FIXFIX) { @@ -72,7 +76,9 @@ void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] sbr->l_A[ch] = sbr->L_E[ch] + 1 - sbr->bs_pointer[ch]; } - estimate_current_envelope(sbr, &adj, Xsbr, ch); + ret = estimate_current_envelope(sbr, &adj, Xsbr, ch); + if (ret > 0) + return 1; calculate_gain(sbr, &adj, ch); @@ -82,6 +88,8 @@ void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] #endif hf_assembly(sbr, &adj, Xsbr, ch); + + return 0; } static uint8_t get_S_mapped(sbr_info *sbr, uint8_t ch, uint8_t l, uint8_t current_band) @@ -125,8 +133,8 @@ static uint8_t get_S_mapped(sbr_info *sbr, uint8_t ch, uint8_t l, uint8_t curren return 0; } -static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, - qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch) +static uint8_t estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, + qmf_t Xsbr[MAX_NTSRHFG][64], uint8_t ch) { uint8_t m, l, j, k, k_l, k_h, p; real_t nrg, div; @@ -142,6 +150,9 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, div = (real_t)(u_i - l_i); + if (div == 0) + div = 1; + for (m = 0; m < sbr->M; m++) { nrg = 0; @@ -192,6 +203,9 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, div = (real_t)((u_i - l_i)*(k_h - k_l)); + if (div == 0) + div = 1; + for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) { for (j = k_l; j < k_h; j++) @@ -225,6 +239,8 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, } } } + + return 0; } #ifdef FIXED_POINT @@ -1342,15 +1358,27 @@ static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, ui { uint8_t l, k, i; uint8_t grouping; + uint8_t S_mapped; for (l = 0; l < sbr->L_E[ch]; l++) { + uint8_t current_res_band = 0; i = 0; grouping = 0; + S_mapped = get_S_mapped(sbr, ch, l, current_res_band); + for (k = sbr->kx; k < sbr->kx + sbr->M - 1; k++) { - if (deg[k + 1] && adj->S_mapped[l][k-sbr->kx] == 0) + if (k == sbr->f_table_res[sbr->f[ch][l]][current_res_band+1]) + { + /* step to next resolution band */ + current_res_band++; + + S_mapped = get_S_mapped(sbr, ch, l, current_res_band); + } + + if (deg[k + 1] && S_mapped == 0) { if (grouping == 0) { @@ -1361,7 +1389,7 @@ static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, ui } else { if (grouping) { - if (adj->S_mapped[l][k-sbr->kx]) + if (S_mapped) { sbr->f_group[l][i] = k; } else { diff --git a/src/libfaad/sbr_hfadj.h b/src/libfaad/sbr_hfadj.h index aeaba32e8..03ef71a0c 100644 --- a/src/libfaad/sbr_hfadj.h +++ b/src/libfaad/sbr_hfadj.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_hfadj.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_hfadj.h,v 1.19 2007/11/01 12:33:35 menno Exp $ **/ #ifndef __SBR_HFADJ_H__ @@ -40,11 +43,11 @@ typedef struct } sbr_hfadj_info; -void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] +uint8_t hf_adjustment(sbr_info *sbr, qmf_t Xsbr[MAX_NTSRHFG][64] #ifdef SBR_LOW_POWER - ,real_t *deg + ,real_t *deg #endif - ,uint8_t ch); + ,uint8_t ch); #ifdef __cplusplus diff --git a/src/libfaad/sbr_hfgen.c b/src/libfaad/sbr_hfgen.c index 688b9a0ea..b0f3219c3 100644 --- a/src/libfaad/sbr_hfgen.c +++ b/src/libfaad/sbr_hfgen.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_hfgen.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_hfgen.c,v 1.26 2007/11/01 12:33:35 menno Exp $ **/ /* High Frequency generation */ @@ -36,7 +39,6 @@ #include "sbr_hfgen.h" #include "sbr_fbt.h" - /* static function declarations */ #ifdef SBR_LOW_POWER static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64], diff --git a/src/libfaad/sbr_hfgen.h b/src/libfaad/sbr_hfgen.h index 27a58be61..a7c842494 100644 --- a/src/libfaad/sbr_hfgen.h +++ b/src/libfaad/sbr_hfgen.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_hfgen.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_hfgen.h,v 1.20 2007/11/01 12:33:35 menno Exp $ **/ #ifndef __SBR_HFGEN_H__ diff --git a/src/libfaad/sbr_huff.c b/src/libfaad/sbr_huff.c index 39ae32b9b..6ba878640 100644 --- a/src/libfaad/sbr_huff.c +++ b/src/libfaad/sbr_huff.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_huff.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_huff.c,v 1.21 2007/11/01 12:33:35 menno Exp $ **/ #include "common.h" diff --git a/src/libfaad/sbr_huff.h b/src/libfaad/sbr_huff.h index 631a43a8d..f749f2e08 100644 --- a/src/libfaad/sbr_huff.h +++ b/src/libfaad/sbr_huff.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_huff.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_huff.h,v 1.21 2007/11/01 12:33:35 menno Exp $ **/ #ifndef __SBR_HUFF_H__ diff --git a/src/libfaad/sbr_noise.h b/src/libfaad/sbr_noise.h index a25fbf3cd..1cf7190de 100644 --- a/src/libfaad/sbr_noise.h +++ b/src/libfaad/sbr_noise.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_noise.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_noise.h,v 1.17 2007/11/01 12:33:35 menno Exp $ **/ #ifndef __SBR_NOISE_H__ diff --git a/src/libfaad/sbr_qmf.c b/src/libfaad/sbr_qmf.c index d534a0442..68f408916 100644 --- a/src/libfaad/sbr_qmf.c +++ b/src/libfaad/sbr_qmf.c @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_qmf.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_qmf.c,v 1.32 2007/11/01 12:33:36 menno Exp $ **/ #include "common.h" @@ -72,7 +75,7 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, #else ALIGN real_t y[32]; #endif - uint16_t in = 0; + uint32_t in = 0; uint8_t l; /* qmf subsample l */ @@ -251,7 +254,7 @@ void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 { ALIGN real_t x[16]; ALIGN real_t y[16]; - int16_t n, k, out = 0; + int32_t n, k, out = 0; uint8_t l; /* qmf subsample l */ @@ -320,7 +323,7 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 { ALIGN real_t x[64]; ALIGN real_t y[64]; - int16_t n, k, out = 0; + int32_t n, k, out = 0; uint8_t l; @@ -392,7 +395,7 @@ void sbr_qmf_synthesis_32(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 #ifndef FIXED_POINT real_t scale = 1.f/64.f; #endif - int16_t n, k, out = 0; + int32_t n, k, out = 0; uint8_t l; @@ -475,7 +478,7 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, qmf_t X[MAX_NTSRHFG][6 #ifndef FIXED_POINT real_t scale = 1.f/64.f; #endif - int16_t n, k, out = 0; + int32_t n, k, out = 0; uint8_t l; diff --git a/src/libfaad/sbr_qmf.h b/src/libfaad/sbr_qmf.h index b1d673d9c..efb167be9 100644 --- a/src/libfaad/sbr_qmf.h +++ b/src/libfaad/sbr_qmf.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_qmf.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_qmf.h,v 1.25 2007/11/01 12:33:36 menno Exp $ **/ #ifndef __SBR_QMF_H__ diff --git a/src/libfaad/sbr_qmf_c.h b/src/libfaad/sbr_qmf_c.h index d9c079520..c2fcd2739 100644 --- a/src/libfaad/sbr_qmf_c.h +++ b/src/libfaad/sbr_qmf_c.h @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_qmf_c.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_qmf_c.h,v 1.17 2007/11/01 12:33:36 menno Exp $ **/ #ifndef __SBR_QMF_C_H__ diff --git a/src/libfaad/sbr_syntax.c b/src/libfaad/sbr_syntax.c index 19cb1b5c2..216c2e9e1 100644 --- a/src/libfaad/sbr_syntax.c +++ b/src/libfaad/sbr_syntax.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_syntax.c,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_syntax.c,v 1.38 2007/11/01 12:33:36 menno Exp $ **/ #include "common.h" @@ -45,6 +48,7 @@ #endif #include "analysis.h" +/* static function declarations */ /* static function declarations */ static void sbr_header(bitfile *ld, sbr_info *sbr); static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq, @@ -131,16 +135,23 @@ static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_f } /* table 2 */ -uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) +uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt, + uint8_t psResetFlag) { uint8_t result = 0; uint16_t num_align_bits = 0; - uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld); + uint16_t num_sbr_bits1 = (uint16_t)faad_get_processed_bits(ld); + uint16_t num_sbr_bits2; uint8_t saved_start_freq, saved_samplerate_mode; uint8_t saved_stop_freq, saved_freq_scale; uint8_t saved_alter_scale, saved_xover_band; +#if (defined(PS_DEC) || defined(DRM_PS)) + if (psResetFlag) + sbr->psResetFlag = psResetFlag; +#endif + #ifdef DRM if (!sbr->Is_DRM_SBR) #endif @@ -206,28 +217,40 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) { calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq, saved_samplerate_mode, saved_freq_scale, - saved_alter_scale, saved_xover_band); + saved_alter_scale, saved_xover_band); } - /* we should be able to safely set result to 0 now */ - result = 0; + /* we should be able to safely set result to 0 now, */ + /* but practise indicates this doesn't work well */ } } else { result = 1; } -#ifdef DRM - if (!sbr->Is_DRM_SBR) -#endif + num_sbr_bits2 = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits1; + + /* check if we read more bits then were available for sbr */ + if (8*cnt < num_sbr_bits2) { - num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits; + faad_resetbits(ld, num_sbr_bits1 + 8*cnt); + num_sbr_bits2 = 8*cnt; - /* check if we read more bits then were available for sbr */ - if (8*cnt < num_sbr_bits) - return 1; +#ifdef PS_DEC + /* turn off PS for the unfortunate case that we randomly read some + * PS data that looks correct */ + sbr->ps_used = 0; +#endif + + /* Make sure it doesn't decode SBR in this frame, or we'll get glitches */ + return 1; + } +#ifdef DRM + if (!sbr->Is_DRM_SBR) +#endif + { /* -4 does not apply, bs_extension_type is re-read in this function */ - num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits; + num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits2; while (num_align_bits > 7) { @@ -364,11 +387,14 @@ static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr) #ifdef DRM /* bs_coupling, from sbr_channel_pair_base_element(bs_amp_res) */ if (sbr->Is_DRM_SBR) + { faad_get1bit(ld); + } #endif if ((result = sbr_grid(ld, sbr, 0)) > 0) return result; + sbr_dtdf(ld, sbr, 0); invf_mode(ld, sbr, 0); sbr_envelope(ld, sbr, 0); @@ -431,7 +457,11 @@ static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr) } else { /* to be safe make it 3, will switch to "default" * in sbr_extension() */ +#ifdef DRM + return 1; +#else sbr->bs_extension_id = 3; +#endif } } #endif @@ -829,6 +859,10 @@ static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr, { sbr->ps = ps_init(get_sr_index(sbr->sample_rate)); } + if (sbr->psResetFlag) + { + sbr->ps->header_read = 0; + } ret = ps_data(sbr->ps, ld, &header); /* enable PS if and only if: a header has been decoded */ @@ -837,6 +871,11 @@ static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr, sbr->ps_used = 1; } + if (header == 1) + { + sbr->psResetFlag = 0; + } + return ret; #endif #ifdef DRM_PS diff --git a/src/libfaad/sbr_syntax.h b/src/libfaad/sbr_syntax.h index 1baa5fec3..a13b2708f 100644 --- a/src/libfaad/sbr_syntax.h +++ b/src/libfaad/sbr_syntax.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_syntax.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_syntax.h,v 1.23 2007/11/01 12:33:36 menno Exp $ **/ #ifndef __SBR_SYNTAX_H__ @@ -55,7 +58,8 @@ extern "C" { #define NOISE_FLOOR_OFFSET 6 -uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt); +uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt, + uint8_t resetFlag); #ifdef __cplusplus } diff --git a/src/libfaad/sbr_tf_grid.c b/src/libfaad/sbr_tf_grid.c index ae741c256..b3b24fd16 100644 --- a/src/libfaad/sbr_tf_grid.c +++ b/src/libfaad/sbr_tf_grid.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_tf_grid.c,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_tf_grid.c,v 1.19 2007/11/01 12:33:36 menno Exp $ **/ /* Time/Frequency grid */ diff --git a/src/libfaad/sbr_tf_grid.h b/src/libfaad/sbr_tf_grid.h index 8772a384a..27a8f908e 100644 --- a/src/libfaad/sbr_tf_grid.h +++ b/src/libfaad/sbr_tf_grid.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_tf_grid.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sbr_tf_grid.h,v 1.17 2007/11/01 12:33:36 menno Exp $ **/ #ifndef __SBR_TF_GRID_H__ diff --git a/src/libfaad/sine_win.h b/src/libfaad/sine_win.h index c7e6ecd6e..e4198da3a 100644 --- a/src/libfaad/sine_win.h +++ b/src/libfaad/sine_win.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sine_win.h,v 1.6 2005/10/29 23:57:07 tmmm Exp $ +** $Id: sine_win.h,v 1.19 2007/11/01 12:33:36 menno Exp $ **/ #ifndef __SINE_WIN_H__ diff --git a/src/libfaad/specrec.c b/src/libfaad/specrec.c index fd4b0653c..ea6ca94b9 100644 --- a/src/libfaad/specrec.c +++ b/src/libfaad/specrec.c @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: specrec.c,v 1.10 2006/06/17 20:43:57 dgp85 Exp $ +** $Id: specrec.c,v 1.60 2007/11/01 12:33:36 menno Exp $ **/ /* @@ -327,6 +330,11 @@ uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics) } #endif + if (ics->max_sfb > ics->num_swb) + { + return 32; + } + /* preparation of sect_sfb_offset for long blocks */ /* also copy the last value! */ #ifdef LD_DEC @@ -348,6 +356,7 @@ uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics) } ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength; ics->swb_offset[ics->num_swb] = hDecoder->frameLength; + ics->swb_offset_max = hDecoder->frameLength; } else { #endif for (i = 0; i < ics->num_swb; i++) @@ -357,6 +366,7 @@ uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics) } ics->sect_sfb_offset[0][ics->num_swb] = hDecoder->frameLength; ics->swb_offset[ics->num_swb] = hDecoder->frameLength; + ics->swb_offset_max = hDecoder->frameLength; #ifdef LD_DEC } #endif @@ -367,9 +377,15 @@ uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics) ics->window_group_length[ics->num_window_groups-1] = 1; ics->num_swb = num_swb_128_window[sf_index]; + if (ics->max_sfb > ics->num_swb) + { + return 32; + } + for (i = 0; i < ics->num_swb; i++) ics->swb_offset[i] = swb_offset_128_window[sf_index][i]; ics->swb_offset[ics->num_swb] = hDecoder->frameLength/8; + ics->swb_offset_max = hDecoder->frameLength/8; for (i = 0; i < ics->num_windows-1; i++) { if (bit_set(ics->scale_factor_grouping, 6-i) == 0) @@ -405,7 +421,7 @@ uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics) } return 0; default: - return 1; + return 32; } } @@ -667,25 +683,46 @@ static uint8_t quant_to_spec(NeAACDecHandle hDecoder, static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, uint8_t output_channels) { - uint8_t mul = 1; + int mul = 1; #ifdef MAIN_DEC /* MAIN object type prediction */ if (hDecoder->object_type == MAIN) { - hDecoder->pred_stat[channel] = (pred_state*)realloc(hDecoder->pred_stat[channel], hDecoder->frameLength * sizeof(pred_state)); - reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); + /* allocate the state only when needed */ + if (hDecoder->pred_stat[channel] != NULL) + { + faad_free(hDecoder->pred_stat[channel]); + hDecoder->pred_stat[channel] = NULL; + } + + hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); + reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); } #endif #ifdef LTP_DEC if (is_ltp_ot(hDecoder->object_type)) { - hDecoder->lt_pred_stat[channel] = (int16_t*)realloc(hDecoder->lt_pred_stat[channel], hDecoder->frameLength*4 * sizeof(int16_t)); - memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); + /* allocate the state only when needed */ + if (hDecoder->lt_pred_stat[channel] != NULL) + { + faad_free(hDecoder->lt_pred_stat[channel]); + hDecoder->lt_pred_stat[channel] = NULL; + } + + hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); + memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); } #endif + if (hDecoder->time_out[channel] != NULL) + { + faad_free(hDecoder->time_out[channel]); + hDecoder->time_out[channel] = NULL; + } + + { mul = 1; #ifdef SBR_DEC hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; @@ -696,28 +733,48 @@ static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; } #endif - hDecoder->time_out[channel] = (real_t*)realloc(hDecoder->time_out[channel], mul*hDecoder->frameLength*sizeof(real_t)); + hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); + } + #if (defined(PS_DEC) || defined(DRM_PS)) if (output_channels == 2) { - hDecoder->time_out[channel+1] = (real_t*)realloc(hDecoder->time_out[channel+1], mul*hDecoder->frameLength*sizeof(real_t)); - memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t)); + if (hDecoder->time_out[channel+1] != NULL) + { + faad_free(hDecoder->time_out[channel+1]); + hDecoder->time_out[channel+1] = NULL; + } + + hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); + memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t)); } #endif - hDecoder->fb_intermed[channel] = (real_t*)realloc(hDecoder->fb_intermed[channel], hDecoder->frameLength*sizeof(real_t)); - memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); + if (hDecoder->fb_intermed[channel] != NULL) + { + faad_free(hDecoder->fb_intermed[channel]); + hDecoder->fb_intermed[channel] = NULL; + } + + hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); + memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); #ifdef SSR_DEC if (hDecoder->object_type == SSR) { - uint16_t k; - hDecoder->ssr_overlap[channel] = (real_t*)realloc(hDecoder->ssr_overlap[channel], 2*hDecoder->frameLength*sizeof(real_t)); + if (hDecoder->ssr_overlap[channel] == NULL) + { + hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); - hDecoder->prev_fmd[channel] = (real_t*)realloc(hDecoder->prev_fmd[channel], 2*hDecoder->frameLength*sizeof(real_t)); + } + if (hDecoder->prev_fmd[channel] == NULL) + { + uint16_t k; + hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); for (k = 0; k < 2*hDecoder->frameLength; k++) hDecoder->prev_fmd[channel][k] = REAL_CONST(-1); + } } #endif @@ -727,7 +784,7 @@ static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, uint8_t channel, uint8_t paired_channel) { - uint8_t mul = 1; + int mul = 1; #ifdef MAIN_DEC /* MAIN object type prediction */ @@ -832,7 +889,8 @@ static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, element *sce, int16_t *spec_data) { - uint8_t retval, output_channels; + uint8_t retval; + int output_channels; ALIGN real_t spec_coef[1024]; #ifdef PROFILE @@ -841,15 +899,38 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, /* always allocate 2 channels, PS can always "suddenly" turn up */ -#if (defined(PS_DEC) || defined(DRM_PS)) - output_channels = hDecoder->ps_used[hDecoder->fr_ch_ele] ? 2 : 1; +#if ( (defined(DRM) && defined(DRM_PS)) ) + output_channels = 2; +#elif defined(PS_DEC) + if (hDecoder->ps_used[hDecoder->fr_ch_ele]) + output_channels = 2; + else + output_channels = 1; #else output_channels = 1; #endif - if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] < output_channels) + if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0) { + /* element_output_channels not set yet */ hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; + } else if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] != output_channels) { + /* element inconsistency */ + + /* this only happens if PS is actually found but not in the first frame + * this means that there is only 1 bitstream element! + */ + + /* reset the allocation */ + hDecoder->element_alloced[hDecoder->fr_ch_ele] = 0; + + hDecoder->element_output_channels[hDecoder->fr_ch_ele] = output_channels; + + //return 21; + } + + if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0) + { retval = allocate_single_channel(hDecoder, sce->channel, output_channels); if (retval > 0) return retval; @@ -870,7 +951,8 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, /* pns decoding */ - pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type); + pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type, + &(hDecoder->__r1), &(hDecoder->__r2)); #ifdef MAIN_DEC /* MAIN object type prediction */ @@ -954,8 +1036,8 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) { - uint8_t ele = hDecoder->fr_ch_ele; - uint8_t ch = sce->channel; + int ele = hDecoder->fr_ch_ele; + int ch = sce->channel; /* following case can happen when forceUpSampling == 1 */ if (hDecoder->sbr[ele] == NULL) @@ -970,9 +1052,9 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, } if (sce->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) - hDecoder->sbr[ele]->maxAACLine = 8*sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; + hDecoder->sbr[ele]->maxAACLine = 8*min(sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)], sce->ics1.swb_offset_max); else - hDecoder->sbr[ele]->maxAACLine = sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)]; + hDecoder->sbr[ele]->maxAACLine = min(sce->ics1.swb_offset[max(sce->ics1.max_sfb-1, 0)], sce->ics1.swb_offset_max); /* check if any of the PS tools is used */ #if (defined(PS_DEC) || defined(DRM_PS)) @@ -995,19 +1077,20 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, { return 23; } +#endif /* copy L to R when no PS is used */ #if (defined(PS_DEC) || defined(DRM_PS)) - if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) && (output_channels == 2)) + if ((hDecoder->ps_used[hDecoder->fr_ch_ele] == 0) && + (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 2)) { - uint8_t ele = hDecoder->fr_ch_ele; - uint8_t ch = sce->channel; - uint16_t frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1; + int ele = hDecoder->fr_ch_ele; + int ch = sce->channel; + int frame_size = (hDecoder->sbr_alloced[ele]) ? 2 : 1; frame_size *= hDecoder->frameLength*sizeof(real_t); memcpy(hDecoder->time_out[ch+1], hDecoder->time_out[ch], frame_size); } -#endif #endif return 0; @@ -1049,10 +1132,13 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st /* pns decoding */ if (ics1->ms_mask_present) { - pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type); + pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type, + &(hDecoder->__r1), &(hDecoder->__r2)); } else { - pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type); - pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type); + pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type, + &(hDecoder->__r1), &(hDecoder->__r2)); + pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type, + &(hDecoder->__r1), &(hDecoder->__r2)); } /* mid/side decoding */ @@ -1204,9 +1290,9 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) { - uint8_t ele = hDecoder->fr_ch_ele; - uint8_t ch0 = cpe->channel; - uint8_t ch1 = cpe->paired_channel; + int ele = hDecoder->fr_ch_ele; + int ch0 = cpe->channel; + int ch1 = cpe->paired_channel; /* following case can happen when forceUpSampling == 1 */ if (hDecoder->sbr[ele] == NULL) @@ -1221,9 +1307,9 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st } if (cpe->ics1.window_sequence == EIGHT_SHORT_SEQUENCE) - hDecoder->sbr[ele]->maxAACLine = 8*cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; + hDecoder->sbr[ele]->maxAACLine = 8*min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)], cpe->ics1.swb_offset_max); else - hDecoder->sbr[ele]->maxAACLine = cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)]; + hDecoder->sbr[ele]->maxAACLine = min(cpe->ics1.swb_offset[max(cpe->ics1.max_sfb-1, 0)], cpe->ics1.swb_offset_max); retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch0], hDecoder->time_out[ch1], diff --git a/src/libfaad/specrec.h b/src/libfaad/specrec.h index da174abe8..f58094cf4 100644 --- a/src/libfaad/specrec.h +++ b/src/libfaad/specrec.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: specrec.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: specrec.h,v 1.32 2007/11/01 12:33:36 menno Exp $ **/ #ifndef __SPECREC_H__ diff --git a/src/libfaad/ssr.c b/src/libfaad/ssr.c index 46517d0c8..368112407 100644 --- a/src/libfaad/ssr.c +++ b/src/libfaad/ssr.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ssr.c,v 1.6 2005/10/29 23:57:07 tmmm Exp $ +** $Id: ssr.c,v 1.19 2007/11/01 12:33:36 menno Exp $ **/ #include "common.h" diff --git a/src/libfaad/ssr.h b/src/libfaad/ssr.h index d1defdc45..7adcf2a11 100644 --- a/src/libfaad/ssr.h +++ b/src/libfaad/ssr.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ssr.h,v 1.6 2005/10/29 23:57:07 tmmm Exp $ +** $Id: ssr.h,v 1.19 2007/11/01 12:33:36 menno Exp $ **/ #ifndef __SSR_H__ diff --git a/src/libfaad/ssr_fb.c b/src/libfaad/ssr_fb.c index fb62c90c6..a977c9411 100644 --- a/src/libfaad/ssr_fb.c +++ b/src/libfaad/ssr_fb.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ssr_fb.c,v 1.6 2005/10/29 23:57:07 tmmm Exp $ +** $Id: ssr_fb.c,v 1.17 2007/11/01 12:33:36 menno Exp $ **/ #include "common.h" diff --git a/src/libfaad/ssr_fb.h b/src/libfaad/ssr_fb.h index 739a4dfbb..3ae4eb04b 100644 --- a/src/libfaad/ssr_fb.h +++ b/src/libfaad/ssr_fb.h @@ -1,6 +1,6 @@ /* -** FAAD - Freeware Advanced Audio Decoder -** Copyright (C) 2002 M. Bakker +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -16,7 +16,16 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** -** $Id: ssr_fb.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id: ssr_fb.h,v 1.16 2007/11/01 12:33:36 menno Exp $ **/ #ifndef __SSR_FB_H__ diff --git a/src/libfaad/ssr_ipqf.c b/src/libfaad/ssr_ipqf.c index 3064285de..6963427c9 100644 --- a/src/libfaad/ssr_ipqf.c +++ b/src/libfaad/ssr_ipqf.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: ssr_ipqf.c,v 1.6 2005/10/29 23:57:07 tmmm Exp $ +** $Id: ssr_ipqf.c,v 1.18 2007/11/01 12:33:39 menno Exp $ **/ #include "common.h" diff --git a/src/libfaad/ssr_ipqf.h b/src/libfaad/ssr_ipqf.h index 360db978b..47299219c 100644 --- a/src/libfaad/ssr_ipqf.h +++ b/src/libfaad/ssr_ipqf.h @@ -1,6 +1,6 @@ /* -** FAAD - Freeware Advanced Audio Decoder -** Copyright (C) 2002 M. Bakker +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -16,7 +16,16 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** -** $Id: ssr_ipqf.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id: ssr_ipqf.h,v 1.17 2007/11/01 12:33:39 menno Exp $ **/ #ifndef __SSR_IPQF_H__ diff --git a/src/libfaad/ssr_win.h b/src/libfaad/ssr_win.h index ddbb3086e..64b0f98bf 100644 --- a/src/libfaad/ssr_win.h +++ b/src/libfaad/ssr_win.h @@ -1,6 +1,6 @@ /* -** FAAD - Freeware Advanced Audio Decoder -** Copyright (C) 2002 M. Bakker +** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding +** Copyright (C) 2003-2005 M. Bakker, Ahead Software AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -16,7 +16,16 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** -** $Id: ssr_win.h,v 1.5 2005/10/29 23:57:07 tmmm Exp $ +** Any non-GPL usage of this software or parts of this software is strictly +** forbidden. +** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** +** Commercial non-GPL licensing of this software is possible. +** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** +** $Id: ssr_win.h,v 1.16 2007/11/01 12:33:39 menno Exp $ **/ #ifndef __SSR_WIN_H__ diff --git a/src/libfaad/structs.h b/src/libfaad/structs.h index db6361a5c..5d957c59e 100644 --- a/src/libfaad/structs.h +++ b/src/libfaad/structs.h @@ -1,28 +1,31 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com +** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program 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 General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: structs.h,v 1.7 2005/10/29 23:57:07 tmmm Exp $ +** $Id: structs.h,v 1.46 2007/11/01 12:33:40 menno Exp $ **/ #ifndef __STRUCTS_H__ @@ -247,6 +250,7 @@ typedef struct uint8_t scale_factor_grouping; uint16_t sect_sfb_offset[8][15*8]; uint16_t swb_offset[52]; + uint16_t swb_offset_max; uint8_t sect_cb[8][15*8]; uint16_t sect_start[8][15*8]; @@ -261,6 +265,7 @@ typedef struct uint8_t ms_used[MAX_WINDOW_GROUPS][MAX_SFB]; uint8_t noise_used; + uint8_t is_used; uint8_t pulse_data_present; uint8_t tns_data_present; @@ -447,6 +452,14 @@ typedef struct int16_t *lt_pred_stat[MAX_CHANNELS]; #endif +#ifdef DRM + uint8_t error_state; +#endif + + /* RNG states */ + uint32_t __r1; + uint32_t __r2; + /* Program Config Element */ uint8_t pce_set; program_config pce; @@ -463,6 +476,7 @@ typedef struct int64_t scalefac_cycles; int64_t requant_cycles; #endif + const unsigned char *cmes; } NeAACDecStruct, *NeAACDecHandle; diff --git a/src/libfaad/syntax.c b/src/libfaad/syntax.c index 6dc9fc57d..373582b7f 100644 --- a/src/libfaad/syntax.c +++ b/src/libfaad/syntax.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: syntax.c,v 1.10 2006/09/26 17:48:24 dgp85 Exp $ +** $Id: syntax.c,v 1.89 2007/11/01 12:33:40 menno Exp $ **/ /* @@ -93,9 +96,11 @@ static void adts_variable_header(adts_header *adts, bitfile *ld); static void adts_error_check(adts_header *adts, bitfile *ld); static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc); static uint8_t excluded_channels(bitfile *ld, drc_info *drc); -#ifdef SCALABLE_DEC -static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, - bitfile *ld, uint8_t this_layer_stereo); +static uint8_t side_info(NeAACDecHandle hDecoder, element *ele, + bitfile *ld, ic_stream *ics, uint8_t scal_flag); +#ifdef DRM +static int8_t DRM_aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, + bitfile *ld, uint8_t this_layer_stereo); #endif @@ -323,7 +328,7 @@ static void decode_sce_lfe(NeAACDecHandle hDecoder, uint8_t channels = hDecoder->fr_channels; uint8_t tag = 0; - if (channels+1 >= MAX_CHANNELS) + if (channels+1 > MAX_CHANNELS) { hInfo->error = 12; return; @@ -413,6 +418,7 @@ void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld, program_config *pce, drc_info *drc) { uint8_t id_syn_ele; + uint8_t ele_this_frame = 0; hDecoder->fr_channels = 0; hDecoder->fr_ch_ele = 0; @@ -429,36 +435,55 @@ void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, { switch (id_syn_ele) { case ID_SCE: + ele_this_frame++; if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); if (hInfo->error > 0) return; break; case ID_CPE: + ele_this_frame++; if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; decode_cpe(hDecoder, hInfo, ld, id_syn_ele); if (hInfo->error > 0) return; break; case ID_LFE: +#ifdef DRM + hInfo->error = 32; +#else + ele_this_frame++; hDecoder->has_lfe++; decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); +#endif if (hInfo->error > 0) return; break; case ID_CCE: /* not implemented yet, but skip the bits */ +#ifdef DRM + hInfo->error = 32; +#else + ele_this_frame++; #ifdef COUPLING_DEC hInfo->error = coupling_channel_element(hDecoder, ld); #else hInfo->error = 6; +#endif #endif if (hInfo->error > 0) return; break; case ID_DSE: + ele_this_frame++; data_stream_element(hDecoder, ld); break; case ID_PCE: + if (ele_this_frame != 0) + { + hInfo->error = 31; + return; + } + ele_this_frame++; /* 14496-4: 5.6.4.1.2.1.3: */ /* program_configuration_element()'s in access units shall be ignored */ program_config_element(pce, ld); @@ -467,6 +492,7 @@ void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, //hDecoder->pce_set = 1; break; case ID_FIL: + ele_this_frame++; /* one sbr_info describes a channel_element not a channel! */ /* if we encounter SBR data here: error */ /* SBR data will be read directly in the SCE/LFE/CPE element */ @@ -577,6 +603,10 @@ static uint8_t single_lfe_channel_element(NeAACDecHandle hDecoder, bitfile *ld, if (retval > 0) return retval; + /* IS not allowed in single channel */ + if (ics->is_used) + return 32; + #ifdef SBR_DEC /* check if next bitstream element is a fill element */ /* if so, read it now so SBR decoding can be done in case of a file with SBR */ @@ -627,6 +657,11 @@ static uint8_t channel_pair_element(NeAACDecHandle hDecoder, bitfile *ld, ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2 DEBUGVAR(1,41,"channel_pair_element(): ms_mask_present")); + if (ics1->ms_mask_present == 3) + { + /* bitstream error */ + return 32; + } if (ics1->ms_mask_present == 1) { uint8_t g, sfb; @@ -730,14 +765,23 @@ static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, uint8_t common_window) { uint8_t retval = 0; + uint8_t ics_reserved_bit; - /* ics->ics_reserved_bit = */ faad_get1bit(ld + ics_reserved_bit = faad_get1bit(ld DEBUGVAR(1,43,"ics_info(): ics_reserved_bit")); + if (ics_reserved_bit != 0) + return 32; ics->window_sequence = (uint8_t)faad_getbits(ld, 2 DEBUGVAR(1,44,"ics_info(): window_sequence")); ics->window_shape = faad_get1bit(ld DEBUGVAR(1,45,"ics_info(): window_shape")); +#ifdef LD_DEC + /* No block switching in LD */ + if ((hDecoder->object_type == LD) && (ics->window_sequence != ONLY_LONG_SEQUENCE)) + return 32; +#endif + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) { ics->max_sfb = (uint8_t)faad_getbits(ld, 4 @@ -753,6 +797,7 @@ static uint8_t ics_info(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, if ((retval = window_grouping_info(hDecoder, ics)) > 0) return retval; + /* should be an error */ /* check the range of max_sfb */ if (ics->max_sfb > ics->num_swb) @@ -922,6 +967,10 @@ static uint8_t coupling_channel_element(NeAACDecHandle hDecoder, bitfile *ld) return result; } + /* IS not allowed in single channel */ + if (ics->is_used) + return 32; + for (c = 1; c < num_gain_element_lists; c++) { uint8_t cge; @@ -1029,7 +1078,8 @@ static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc hDecoder->sbr_present_flag = 1; /* parse the SBR data */ - hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count); + hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count, + hDecoder->postSeekResetFlag); #if 0 if (hDecoder->sbr[sbr_ele]->ret > 0) @@ -1049,10 +1099,14 @@ static uint8_t fill_element(NeAACDecHandle hDecoder, bitfile *ld, drc_info *drc #endif } else { #endif +#ifndef DRM while (count > 0) { count -= extension_payload(ld, drc, count); } +#else + return 30; +#endif #ifdef SBR_DEC } #endif @@ -1157,10 +1211,10 @@ static void gain_control_data(bitfile *ld, ic_stream *ics) } #endif -#ifdef SCALABLE_DEC +#ifdef DRM /* Table 4.4.13 ASME */ -void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, - bitfile *ld, program_config *pce, drc_info *drc) +void DRM_aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, + bitfile *ld, program_config *pce, drc_info *drc) { uint8_t retval = 0; uint8_t channels = hDecoder->fr_channels = 0; @@ -1175,7 +1229,7 @@ void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo hDecoder->fr_ch_ele = 0; - hInfo->error = aac_scalable_main_header(hDecoder, ics1, ics2, ld, this_layer_stereo); + hInfo->error = DRM_aac_scalable_main_header(hDecoder, ics1, ics2, ld, this_layer_stereo); if (hInfo->error > 0) return; @@ -1189,22 +1243,77 @@ void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo hDecoder->element_id[0] = ID_SCE; } - for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++) + if (this_layer_stereo) { - ic_stream *ics; - if (ch == 0) - { - ics = ics1; - spec_data = spec_data1; - } else { - ics = ics2; - spec_data = spec_data2; - } + cpe.channel = 0; + cpe.paired_channel = 1; + } + + + /* Stereo2 / Mono1 */ + ics1->tns_data_present = faad_get1bit(ld); - hInfo->error = individual_channel_stream(hDecoder, &cpe, ld, ics, 1, spec_data); +#if defined(LTP_DEC) + ics1->ltp.data_present = faad_get1bit(ld); +#elif defined (DRM) + if(faad_get1bit(ld)) { + hInfo->error = 26; + return; + } +#else + faad_get1bit(ld); +#endif + + hInfo->error = side_info(hDecoder, &cpe, ld, ics1, 1); + if (hInfo->error > 0) + return; + if (this_layer_stereo) + { + /* Stereo3 */ + ics2->tns_data_present = faad_get1bit(ld); +#ifdef LTP_DEC + ics1->ltp.data_present = +#endif + faad_get1bit(ld); + hInfo->error = side_info(hDecoder, &cpe, ld, ics2, 1); if (hInfo->error > 0) return; } + /* Stereo4 / Mono2 */ + if (ics1->tns_data_present) + tns_data(ics1, &(ics1->tns), ld); + if (this_layer_stereo) + { + /* Stereo5 */ + if (ics2->tns_data_present) + tns_data(ics2, &(ics2->tns), ld); + } + +#ifdef DRM + /* CRC check */ + if (hDecoder->object_type == DRM_ER_LC) + { + if ((hInfo->error = (uint8_t)faad_check_CRC(ld, (uint16_t)faad_get_processed_bits(ld) - 8)) > 0) + return; + } +#endif + + /* Stereo6 / Mono3 */ + /* error resilient spectral data decoding */ + if ((hInfo->error = reordered_spectral_data(hDecoder, ics1, ld, spec_data1)) > 0) + { + return; + } + if (this_layer_stereo) + { + /* Stereo7 */ + /* error resilient spectral data decoding */ + if ((hInfo->error = reordered_spectral_data(hDecoder, ics2, ld, spec_data2)) > 0) + { + return; + } + } + #ifdef DRM #ifdef SBR_DEC @@ -1244,6 +1353,7 @@ void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo /* Set SBR data */ /* consider 8 bits from AAC-CRC */ + /* SBR buffer size is original buffer size minus AAC buffer size */ count = (uint16_t)bit2byte(buffer_size*8 - bitsconsumed); faad_initbits(&ld_sbr, revbuffer, count); @@ -1252,7 +1362,7 @@ void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo faad_getbits(&ld_sbr, 8); /* Skip 8-bit CRC */ - hDecoder->sbr[0]->ret = sbr_extension_data(&ld_sbr, hDecoder->sbr[0], count); + hDecoder->sbr[0]->ret = sbr_extension_data(&ld_sbr, hDecoder->sbr[0], count, hDecoder->postSeekResetFlag); #if (defined(PS_DEC) || defined(DRM_PS)) if (hDecoder->sbr[0]->ps_used) { @@ -1261,6 +1371,11 @@ void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo } #endif + if (ld_sbr.error) + { + hDecoder->sbr[0]->ret = 1; + } + /* check CRC */ /* no need to check it if there was already an error */ if (hDecoder->sbr[0]->ret == 0) @@ -1269,7 +1384,7 @@ void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo /* SBR data was corrupted, disable it until the next header */ if (hDecoder->sbr[0]->ret != 0) { - hDecoder->sbr[0]->header_count = 0; + hDecoder->sbr[0]->header_count = 0; } faad_endbits(&ld_sbr); @@ -1308,15 +1423,18 @@ void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo } /* Table 4.4.15 */ -static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, - bitfile *ld, uint8_t this_layer_stereo) +static int8_t DRM_aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, + bitfile *ld, uint8_t this_layer_stereo) { uint8_t retval = 0; uint8_t ch; ic_stream *ics; + uint8_t ics_reserved_bit; - /* ics1->ics_reserved_bit = */ faad_get1bit(ld + ics_reserved_bit = faad_get1bit(ld DEBUGVAR(1,300,"aac_scalable_main_header(): ics_reserved_bits")); + if (ics_reserved_bit != 0) + return 32; ics1->window_sequence = (uint8_t)faad_getbits(ld, 2 DEBUGVAR(1,301,"aac_scalable_main_header(): window_sequence")); ics1->window_shape = faad_get1bit(ld @@ -1346,6 +1464,11 @@ static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, { ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2 DEBUGVAR(1,306,"aac_scalable_main_header(): ms_mask_present")); + if (ics1->ms_mask_present == 3) + { + /* bitstream error */ + return 32; + } if (ics1->ms_mask_present == 1) { uint8_t g, sfb; @@ -1364,70 +1487,12 @@ static int8_t aac_scalable_main_header(NeAACDecHandle hDecoder, ic_stream *ics1, ics1->ms_mask_present = 0; } - if (0) - { - faad_get1bit(ld - DEBUGVAR(1,308,"aac_scalable_main_header(): tns_channel_mono_layer")); - } - - for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++) - { - if (ch == 0) - ics = ics1; - else - ics = ics2; - - if ( 1 /*!tvq_layer_pesent || (tns_aac_tvq_en[ch] == 1)*/) - { - if ((ics->tns_data_present = faad_get1bit(ld - DEBUGVAR(1,309,"aac_scalable_main_header(): tns_data_present"))) & 1) - { -#ifdef DRM - /* different order of data units in DRM */ - if (hDecoder->object_type != DRM_ER_LC) -#endif - { - tns_data(ics, &(ics->tns), ld); - } - } - } -#if 0 - if (0 /*core_flag || tvq_layer_pesent*/) - { - if ((ch==0) || ((ch==1) && (core_stereo || tvq_stereo)) - diff_control_data(); - if (mono_stereo_flag) - diff_control_data_lr(); - } else { -#endif - if (( -#ifdef LTP_DEC - ics->ltp.data_present = -#endif - faad_get1bit(ld DEBUGVAR(1,310,"aac_scalable_main_header(): ltp.data_present"))) & 1) - { -#ifdef LTP_DEC - if ((retval = ltp_data(hDecoder, ics, &(ics->ltp), ld)) > 0) - { - return retval; - } -#else - return 26; -#endif - } -#if 0 - } -#endif - } - return 0; } #endif -/* Table 4.4.24 */ -static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele, - bitfile *ld, ic_stream *ics, uint8_t scal_flag, - int16_t *spec_data) +static uint8_t side_info(NeAACDecHandle hDecoder, element *ele, + bitfile *ld, ic_stream *ics, uint8_t scal_flag) { uint8_t result; @@ -1513,6 +1578,21 @@ static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele, if ((result = rvlc_decode_scale_factors(ics, ld)) > 0) return result; } +#endif + + return 0; +} + +/* Table 4.4.24 */ +static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele, + bitfile *ld, ic_stream *ics, uint8_t scal_flag, + int16_t *spec_data) +{ + uint8_t result; + + result = side_info(hDecoder, ele, ld, ics, scal_flag); + if (result > 0) + return result; if (hDecoder->object_type >= ER_OBJECT_START) { @@ -1523,10 +1603,13 @@ static uint8_t individual_channel_stream(NeAACDecHandle hDecoder, element *ele, #ifdef DRM /* CRC check */ if (hDecoder->object_type == DRM_ER_LC) + { if ((result = (uint8_t)faad_check_CRC(ld, (uint16_t)faad_get_processed_bits(ld) - 8)) > 0) return result; + } #endif +#ifdef ERROR_RESILIENCE if (hDecoder->aacSpectralDataResilienceFlag) { /* error resilient spectral data decoding */ @@ -1594,7 +1677,7 @@ static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld /* if "faad_getbits" detects error and returns "0", "k" is never incremented and we cannot leave the while loop */ - if ((ld->error != 0) || (ld->no_more_reading)) + if (ld->error != 0) return 14; #ifdef ERROR_RESILIENCE @@ -1605,12 +1688,23 @@ static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld ics->sect_cb[g][i] = (uint8_t)faad_getbits(ld, sect_cb_bits DEBUGVAR(1,71,"section_data(): sect_cb")); + if (ics->sect_cb[g][i] == 12) + return 32; + #if 0 printf("%d\n", ics->sect_cb[g][i]); #endif +#ifndef DRM if (ics->sect_cb[g][i] == NOISE_HCB) ics->noise_used = 1; +#else + /* PNS not allowed in DRM */ + if (ics->sect_cb[g][i] == NOISE_HCB) + return 29; +#endif + if (ics->sect_cb[g][i] == INTENSITY_HCB2 || ics->sect_cb[g][i] == INTENSITY_HCB) + ics->is_used = 1; #ifdef ERROR_RESILIENCE if (hDecoder->aacSectionDataResilienceFlag) @@ -1651,10 +1745,18 @@ static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld printf("%d\n", ics->sect_end[g][i]); #endif - if (k + sect_len >= 8*15) - return 15; - if (i >= 8*15) - return 15; + if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) + { + if (k + sect_len > 8*15) + return 15; + if (i >= 8*15) + return 15; + } else { + if (k + sect_len > MAX_SFB) + return 15; + if (i >= MAX_SFB) + return 15; + } for (sfb = k; sfb < k + sect_len; sfb++) { @@ -1675,6 +1777,13 @@ static uint8_t section_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld i++; } ics->num_sec[g] = i; + + /* the sum of all sect_len_incr elements for a given window + * group shall equal max_sfb */ + if (k != ics->max_sfb) + { + return 32; + } #if 0 printf("%d\n", ics->num_sec[g]); #endif @@ -1735,6 +1844,7 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld) break; case NOISE_HCB: /* noise books */ +#ifndef DRM /* decode noise energy */ if (noise_pcm_flag) { @@ -1750,6 +1860,10 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld) #ifdef SF_PRINT printf("%d\n", ics->scale_factors[g][sfb]); #endif +#else + /* PNS not allowed in DRM */ + return 29; +#endif break; default: /* spectral books */ @@ -2048,11 +2162,11 @@ static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count) return n; case EXT_FILL_DATA: /* fill_nibble = */ faad_getbits(ld, 4 - DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be '0000' */ + DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be ‘0000’ */ for (i = 0; i < count-1; i++) { /* fill_byte[i] = */ faad_getbits(ld, 8 - DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be '10100101' */ + DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be ‘10100101’ */ } return count; case EXT_DATA_ELEMENT: @@ -2127,7 +2241,7 @@ static uint8_t dynamic_range_info(bitfile *ld, drc_info *drc) n++; drc->num_bands += band_incr; - for (i = 0; i < drc->num_bands; i++); + for (i = 0; i < drc->num_bands; i++) { drc->band_top[i] = (uint8_t)faad_getbits(ld, 8 DEBUGVAR(1,97,"dynamic_range_info(): band_top")); diff --git a/src/libfaad/syntax.h b/src/libfaad/syntax.h index a047dd644..123c4573f 100644 --- a/src/libfaad/syntax.h +++ b/src/libfaad/syntax.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: syntax.h,v 1.10 2005/10/29 23:57:07 tmmm Exp $ +** $Id: syntax.h,v 1.58 2007/11/01 12:33:40 menno Exp $ **/ #ifndef __SYNTAX_H__ @@ -114,9 +117,10 @@ void raw_data_block(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, bitfile *ld, program_config *pce, drc_info *drc); uint8_t reordered_spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, int16_t *spectral_data); -void aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, - bitfile *ld, program_config *pce, drc_info *drc); - +#ifdef DRM +void DRM_aac_scalable_main_element(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, + bitfile *ld, program_config *pce, drc_info *drc); +#endif #ifdef __cplusplus } diff --git a/src/libfaad/tns.c b/src/libfaad/tns.c index bb4db731a..611865204 100644 --- a/src/libfaad/tns.c +++ b/src/libfaad/tns.c @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: tns.c,v 1.8 2005/10/29 23:57:07 tmmm Exp $ +** $Id: tns.c,v 1.40 2007/11/01 12:33:40 menno Exp $ **/ #include "common.h" @@ -106,11 +109,11 @@ void tns_decode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); start = min(start, ics->max_sfb); - start = ics->swb_offset[start]; + start = min(ics->swb_offset[start], ics->swb_offset_max); end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); end = min(end, ics->max_sfb); - end = ics->swb_offset[end]; + end = min(ics->swb_offset[end], ics->swb_offset_max); size = end - start; if (size <= 0) @@ -160,11 +163,11 @@ void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); start = min(start, ics->max_sfb); - start = ics->swb_offset[start]; + start = min(ics->swb_offset[start], ics->swb_offset_max); end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); end = min(end, ics->max_sfb); - end = ics->swb_offset[end]; + end = min(ics->swb_offset[end], ics->swb_offset_max); size = end - start; if (size <= 0) @@ -292,7 +295,7 @@ static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l y = *spectrum; for (j = 0; j < order; j++) - y += MUL_C(state[j], lpc[j+1]); + y += MUL_C(state[state_index+j], lpc[j+1]); /* double ringbuffer state */ state_index--; diff --git a/src/libfaad/tns.h b/src/libfaad/tns.h index fc77894d8..8848c3f2d 100644 --- a/src/libfaad/tns.h +++ b/src/libfaad/tns.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -19,10 +19,13 @@ ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** The "appropriate copyright message" mentioned in section 2c of the GPLv2 +** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: tns.h,v 1.8 2005/10/29 23:57:07 tmmm Exp $ +** $Id: tns.h,v 1.23 2007/11/01 12:33:41 menno Exp $ **/ #ifndef __TNS_H__ -- cgit v1.2.3 From 5a02b8117044e4ba6be61d21e069fc2fbfc2fa23 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 13 Aug 2008 14:29:21 +0100 Subject: Remove faad.h since we don't use it. --- src/libfaad/faad.h | 217 ----------------------------------------------------- 1 file changed, 217 deletions(-) delete mode 100644 src/libfaad/faad.h (limited to 'src') diff --git a/src/libfaad/faad.h b/src/libfaad/faad.h deleted file mode 100644 index e46c31d87..000000000 --- a/src/libfaad/faad.h +++ /dev/null @@ -1,217 +0,0 @@ -/* -** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program 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 General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -** -** Any non-GPL usage of this software or parts of this software is strictly -** forbidden. -** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. -** -** $Id: faad.h,v 1.7 2004/12/03 01:15:30 tmattern Exp $ -**/ - -#ifndef __AACDEC_H__ -#define __AACDEC_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifdef _WIN32 - #pragma pack(push, 8) - #ifndef FAADAPI - #define FAADAPI __cdecl - #endif -#else - #ifndef FAADAPI - #define FAADAPI - #endif -#endif - -#define FAAD2_VERSION "2.0 " - -/* object types for AAC */ -#define MAIN 1 -#define LC 2 -#define SSR 3 -#define LTP 4 -#define HE_AAC 5 -#define ER_LC 17 -#define ER_LTP 19 -#define LD 23 -#define DRM_ER_LC 27 /* special object type for DRM */ - -/* header types */ -#define RAW 0 -#define ADIF 1 -#define ADTS 2 - -/* SBR signalling */ -#define NO_SBR 0 -#define SBR_UPSAMPLED 1 -#define SBR_DOWNSAMPLED 2 -#define NO_SBR_UPSAMPLED 3 - -/* library output formats */ -#define FAAD_FMT_16BIT 1 -#define FAAD_FMT_24BIT 2 -#define FAAD_FMT_32BIT 3 -#define FAAD_FMT_FLOAT 4 -#define FAAD_FMT_DOUBLE 5 - -/* Capabilities */ -#define LC_DEC_CAP (1<<0) /* Can decode LC */ -#define MAIN_DEC_CAP (1<<1) /* Can decode MAIN */ -#define LTP_DEC_CAP (1<<2) /* Can decode LTP */ -#define LD_DEC_CAP (1<<3) /* Can decode LD */ -#define ERROR_RESILIENCE_CAP (1<<4) /* Can decode ER */ -#define FIXED_POINT_CAP (1<<5) /* Fixed point */ - -/* Channel definitions */ -#define FRONT_CHANNEL_CENTER (1) -#define FRONT_CHANNEL_LEFT (2) -#define FRONT_CHANNEL_RIGHT (3) -#define SIDE_CHANNEL_LEFT (4) -#define SIDE_CHANNEL_RIGHT (5) -#define BACK_CHANNEL_LEFT (6) -#define BACK_CHANNEL_RIGHT (7) -#define BACK_CHANNEL_CENTER (8) -#define LFE_CHANNEL (9) -#define UNKNOWN_CHANNEL (0) - -/* DRM channel definitions */ -#define DRMCH_MONO 1 -#define DRMCH_STEREO 2 -#define DRMCH_SBR_MONO 3 -#define DRMCH_SBR_LC_STEREO 4 -#define DRMCH_SBR_STEREO 5 - - -/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel, - so at least so much bytes per channel should be available in this stream */ -#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */ - - -typedef void *faacDecHandle; - -typedef struct mp4AudioSpecificConfig -{ - /* Audio Specific Info */ - unsigned char objectTypeIndex; - unsigned char samplingFrequencyIndex; - unsigned long samplingFrequency; - unsigned char channelsConfiguration; - - /* GA Specific Info */ - unsigned char frameLengthFlag; - unsigned char dependsOnCoreCoder; - unsigned short coreCoderDelay; - unsigned char extensionFlag; - unsigned char aacSectionDataResilienceFlag; - unsigned char aacScalefactorDataResilienceFlag; - unsigned char aacSpectralDataResilienceFlag; - unsigned char epConfig; - - char sbr_present_flag; - char forceUpSampling; -} mp4AudioSpecificConfig; - -typedef struct faacDecConfiguration -{ - unsigned char defObjectType; - unsigned long defSampleRate; - unsigned char outputFormat; - unsigned char downMatrix; - unsigned char useOldADTSFormat; - unsigned char dontUpSampleImplicitSBR; -} faacDecConfiguration, *faacDecConfigurationPtr; - -typedef struct faacDecFrameInfo -{ - unsigned long bytesconsumed; - unsigned long samples; - unsigned char channels; - unsigned char error; - unsigned long samplerate; - - /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */ - unsigned char sbr; - - /* MPEG-4 ObjectType */ - unsigned char object_type; - - /* AAC header type; MP4 will be signalled as RAW also */ - unsigned char header_type; - - /* multichannel configuration */ - unsigned char num_front_channels; - unsigned char num_side_channels; - unsigned char num_back_channels; - unsigned char num_lfe_channels; - unsigned char channel_position[64]; -} faacDecFrameInfo; - -char* FAADAPI faacDecGetErrorMessage(unsigned char errcode); - -unsigned long FAADAPI faacDecGetCapabilities(void); - -faacDecHandle FAADAPI faacDecOpen(void); - -faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder); - -unsigned char FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder, - faacDecConfigurationPtr config); - -/* Init the library based on info from the AAC file (ADTS/ADIF) */ -long FAADAPI faacDecInit(faacDecHandle hDecoder, - unsigned char *buffer, - unsigned long buffer_size, - unsigned long *samplerate, - unsigned char *channels); - -/* Init the library using a DecoderSpecificInfo */ -char FAADAPI faacDecInit2(faacDecHandle hDecoder, unsigned char *pBuffer, - unsigned long SizeOfDecoderSpecificInfo, - unsigned long *samplerate, unsigned char *channels); - -/* Init the library for DRM */ -char FAADAPI faacDecInitDRM(faacDecHandle hDecoder, unsigned long samplerate, - unsigned char channels); - -void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, long frame); - -void FAADAPI faacDecClose(faacDecHandle hDecoder); - -void* FAADAPI faacDecDecode(faacDecHandle hDecoder, - faacDecFrameInfo *hInfo, - unsigned char *buffer, - unsigned long buffer_size); - -char FAADAPI AudioSpecificConfig(unsigned char *pBuffer, - unsigned long buffer_size, - mp4AudioSpecificConfig *mp4ASC); - -#ifdef _WIN32 - #pragma pack(pop) -#endif - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif -- cgit v1.2.3 From 065ab726cb977220dd65f398fa5e3543ad657ed4 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 13 Aug 2008 14:31:51 +0100 Subject: Allow (and prefer) use of external libfaad. --- src/libfaad/Makefile.am | 19 +++++++++++++++---- src/libfaad/xine_faad_decoder.c | 4 ++++ 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/libfaad/Makefile.am b/src/libfaad/Makefile.am index 92c1fe585..f36fb608a 100644 --- a/src/libfaad/Makefile.am +++ b/src/libfaad/Makefile.am @@ -10,8 +10,10 @@ xineplug_LTLIBRARIES = $(faad_module) VPATH = @srcdir@:@srcdir@/codebook: -xineplug_decode_faad_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS) -fno-strict-aliasing -xineplug_decode_faad_la_SOURCES = \ +if EXTERNAL_LIBFAAD +libfaad_sources = +else +libfaad_sources = \ bits.c \ cfft.c \ common.c \ @@ -49,11 +51,21 @@ xineplug_decode_faad_la_SOURCES = \ ssr_fb.c \ ssr_ipqf.c \ syntax.c \ - tns.c \ + tns.c +endif + +xineplug_decode_faad_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS) -fno-strict-aliasing +xineplug_decode_faad_la_SOURCES = \ + $(libfaad_sources) \ xine_faad_decoder.c xineplug_decode_faad_la_LDFLAGS = $(xineplug_ldflags) +if EXTERNAL_LIBFAAD +xineplug_decode_faad_la_LIBADD = $(XINE_LIB) -lfaad -lm $(LTLIBINTL) +else xineplug_decode_faad_la_LIBADD = $(XINE_LIB) -lm $(LTLIBINTL) +endif + noinst_HEADERS = \ analysis.h \ @@ -104,7 +116,6 @@ noinst_HEADERS = \ structs.h \ syntax.h \ tns.h \ - neaacdec.h \ codebook/hcb.h \ codebook/hcb_1.h \ codebook/hcb_2.h \ diff --git a/src/libfaad/xine_faad_decoder.c b/src/libfaad/xine_faad_decoder.c index 6f86d95fd..ae71af155 100644 --- a/src/libfaad/xine_faad_decoder.c +++ b/src/libfaad/xine_faad_decoder.c @@ -35,10 +35,14 @@ #include "audio_out.h" #include "buffer.h" #include "xineutils.h" +#ifdef HAVE_FAAD_H +#include +#else #include "common.h" #include "structs.h" #include "decoder.h" #include "syntax.h" +#endif #define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */ -- cgit v1.2.3 From 18a6a7d463733430c29e84e9b068bbb94ff65624 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 13 Aug 2008 15:06:07 +0100 Subject: Apply the deinterlacer size fix to the XCB Xv plugin. --- src/video_out/video_out_xcbxv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/video_out/video_out_xcbxv.c b/src/video_out/video_out_xcbxv.c index b6e5544c3..807bb766d 100644 --- a/src/video_out/video_out_xcbxv.c +++ b/src/video_out/video_out_xcbxv.c @@ -435,7 +435,7 @@ static void xv_deinterlace_frame (xv_driver_t *this) { for( i = 0; i < VO_NUM_RECENT_FRAMES; i++ ) if( this->recent_frames[i] && this->recent_frames[i]->width == frame->width && this->recent_frames[i]->height == frame->height ) - recent_bitmaps[i] = this->recent_frames[i]->image + frame->width*frame->height; + recent_bitmaps[i] = this->recent_frames[i]->image + this->deinterlace_frame.xv_width*frame->height; else recent_bitmaps[i] = NULL; -- cgit v1.2.3 From 4aef516243988c11ad23ed11c373228598f3e48b Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 13 Aug 2008 17:33:04 +0100 Subject: Use size_t for data length variables. --- src/demuxers/demux_matroska.c | 24 ++++++++++++------------ src/demuxers/demux_mod.c | 2 +- src/demuxers/demux_real.c | 13 +++++++------ src/demuxers/demux_realaudio.c | 2 +- src/demuxers/id3.h | 12 ++++++------ 5 files changed, 27 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index 5faebf61d..a8af6c44f 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -106,7 +106,7 @@ typedef struct { /* block */ uint8_t *block_data; - int block_data_size; + size_t block_data_size; /* current tracks */ matroska_track_t *video_track; /* to remove */ @@ -875,7 +875,7 @@ static void init_codec_vobsub(demux_matroska_t *this, static void handle_realvideo (demux_plugin_t *this_gen, matroska_track_t *track, int decoder_flags, - uint8_t *data, int data_len, + uint8_t *data, size_t data_len, int64_t data_pts, int data_duration, int input_normpos, int input_time) { demux_matroska_t *this = (demux_matroska_t *) this_gen; @@ -924,7 +924,7 @@ static void handle_realvideo (demux_plugin_t *this_gen, matroska_track_t *track, static void handle_sub_ssa (demux_plugin_t *this_gen, matroska_track_t *track, int decoder_flags, - uint8_t *data, int data_len, + uint8_t *data, size_t data_len, int64_t data_pts, int data_duration, int input_normpos, int input_time) { buf_element_t *buf; @@ -999,7 +999,7 @@ static void handle_sub_ssa (demux_plugin_t *this_gen, matroska_track_t *track, static void handle_sub_utf8 (demux_plugin_t *this_gen, matroska_track_t *track, int decoder_flags, - uint8_t *data, int data_len, + uint8_t *data, size_t data_len, int64_t data_pts, int data_duration, int input_normpos, int input_time) { demux_matroska_t *this = (demux_matroska_t *) this_gen; @@ -1046,7 +1046,7 @@ static void handle_sub_utf8 (demux_plugin_t *this_gen, matroska_track_t *track, */ static void handle_vobsub (demux_plugin_t *this_gen, matroska_track_t *track, int decoder_flags, - uint8_t *data, int data_len, + uint8_t *data, size_t data_len, int64_t data_pts, int data_duration, int input_normpos, int input_time) { demux_matroska_t *this = (demux_matroska_t *) this_gen; @@ -1731,7 +1731,7 @@ static int parse_tags(demux_matroska_t *this) { return 1; } -static void alloc_block_data (demux_matroska_t *this, int len) { +static void alloc_block_data (demux_matroska_t *this, size_t len) { /* memory management */ if (this->block_data_size < len) { if (this->block_data) @@ -1803,7 +1803,7 @@ static int find_track_by_id(demux_matroska_t *this, int track_num, } -static int read_block_data (demux_matroska_t *this, int len) { +static int read_block_data (demux_matroska_t *this, size_t len) { alloc_block_data(this, len); /* block datas */ @@ -1826,7 +1826,7 @@ static int parse_int16(uint8_t *data) { return value; } -static int parse_block (demux_matroska_t *this, uint64_t block_size, +static int parse_block (demux_matroska_t *this, size_t block_size, uint64_t cluster_timecode, uint64_t block_duration, int normpos, int is_key) { matroska_track_t *track; @@ -1892,7 +1892,7 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, } if (lacing == MATROSKA_NO_LACING) { - int block_size_left; + size_t block_size_left; lprintf("no lacing\n"); block_size_left = (this->block_data + block_size) - data; @@ -1912,9 +1912,9 @@ static int parse_block (demux_matroska_t *this, uint64_t block_size, } } else { - int block_size_left; + size_t block_size_left; uint8_t lace_num; - int frame[MAX_FRAMES]; + size_t frame[MAX_FRAMES]; int i; /* number of laced frames */ @@ -2055,7 +2055,7 @@ static int parse_block_group(demux_matroska_t *this, off_t block_pos = 0; off_t file_len = 0; int normpos = 0; - int block_len = 0; + size_t block_len = 0; int is_key = 1; while (next_level == 3) { diff --git a/src/demuxers/demux_mod.c b/src/demuxers/demux_mod.c index 2c0f44afa..9bb17a990 100644 --- a/src/demuxers/demux_mod.c +++ b/src/demuxers/demux_mod.c @@ -73,7 +73,7 @@ typedef struct { char *title; char *artist; char *copyright; - off_t filesize; + size_t filesize; char *buffer; diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 957cd5caa..27f7a2634 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -90,11 +90,11 @@ typedef struct { uint32_t start_time; uint32_t preroll; uint32_t duration; - char stream_name_size; + size_t stream_name_size; char *stream_name; - char mime_type_size; + size_t mime_type_size; char *mime_type; - uint32_t type_specific_len; + size_t type_specific_len; char *type_specific_data; } mdpr_t; @@ -115,7 +115,7 @@ typedef struct { mdpr_t *mdpr; int sps, cfs, w, h; int block_align; - int frame_size; + size_t frame_size; uint8_t *frame_buffer; uint32_t frame_num_bytes; uint32_t sub_packet_cnt; @@ -366,7 +366,7 @@ static void real_parse_audio_specific_data (demux_real_t *this, stream->sub_packet_cnt = 0; xprintf (this->stream->xine, XINE_VERBOSITY_LOG, - "demux_real: buf type 0x%08x frame size %dblock align %d\n", stream->buf_type, + "demux_real: buf type 0x%08x frame size %zu block align %d\n", stream->buf_type, stream->frame_size, stream->block_align); } @@ -1370,7 +1370,8 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { int cfs = this->audio_stream->cfs; int w = this->audio_stream->w; int spc = this->audio_stream->sub_packet_cnt; - int x, pos; + int x; + off_t pos; switch (this->audio_stream->buf_type) { case BUF_AUDIO_28_8: diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c index 5b713cb60..1c39c6208 100644 --- a/src/demuxers/demux_realaudio.c +++ b/src/demuxers/demux_realaudio.c @@ -67,7 +67,7 @@ typedef struct { uint32_t cfs; uint16_t w, h; int frame_len; - int frame_size; + size_t frame_size; uint8_t *frame_buffer; unsigned char *header; diff --git a/src/demuxers/id3.h b/src/demuxers/id3.h index 9cab594a1..41babe2b4 100644 --- a/src/demuxers/id3.h +++ b/src/demuxers/id3.h @@ -103,22 +103,22 @@ typedef struct { uint32_t id; uint8_t revision; uint8_t flags; - uint32_t size; + size_t size; } id3v2_header_t; typedef struct { uint32_t id; - uint32_t size; + size_t size; } id3v22_frame_header_t; typedef struct { uint32_t id; - uint32_t size; + size_t size; uint16_t flags; } id3v23_frame_header_t; typedef struct { - uint32_t size; + size_t size; uint16_t flags; uint32_t padding_size; uint32_t crc; @@ -128,12 +128,12 @@ typedef id3v2_header_t id3v24_footer_t; typedef struct { uint32_t id; - uint32_t size; + size_t size; uint16_t flags; } id3v24_frame_header_t; typedef struct { - uint32_t size; + size_t size; uint8_t flags; uint32_t crc; uint8_t restrictions; -- cgit v1.2.3 From b9dc65ff35387961d9526f5c443f9af43a3c1909 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 13 Aug 2008 17:33:04 +0100 Subject: Check for allocation failures. --- src/demuxers/demux_mng.c | 4 +++- src/demuxers/demux_mod.c | 6 +++++- src/demuxers/demux_real.c | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_mng.c b/src/demuxers/demux_mng.c index a32374048..0fcdb24ff 100644 --- a/src/demuxers/demux_mng.c +++ b/src/demuxers/demux_mng.c @@ -116,7 +116,9 @@ static mng_bool mymng_process_header(mng_handle mngh, mng_uint32 width, mng_uint this->bih.biHeight = height; this->left_edge = (this->bih.biWidth - width) / 2; - this->image = malloc(this->bih.biWidth * height * 3); + this->image = malloc((mng_size_t)this->bih.biWidth * (mng_size_t)height * 3); + if (!this->image) + return MNG_FALSE; mng_set_canvasstyle(mngh, MNG_CANVAS_RGB8); diff --git a/src/demuxers/demux_mod.c b/src/demuxers/demux_mod.c index 9bb17a990..bffcf36d8 100644 --- a/src/demuxers/demux_mod.c +++ b/src/demuxers/demux_mod.c @@ -134,7 +134,11 @@ static int open_mod_file(demux_mod_t *this) { /* Get size and create buffer */ this->filesize = this->input->get_length(this->input); this->buffer = (char *)malloc(this->filesize); - + if(!this->buffer) { + xine_log(this->stream->xine, XINE_LOG_PLUGIN, "modplug - allocation failure\n"); + return 0; + } + /* Seek to beginning */ this->input->seek(this->input, 0, SEEK_SET); diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 27f7a2634..fdb913ef4 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -365,6 +365,10 @@ static void real_parse_audio_specific_data (demux_real_t *this, stream->frame_num_bytes = 0; stream->sub_packet_cnt = 0; + if (!stream->frame_buffer) + xprintf (this->stream->xine, XINE_VERBOSITY_LOG, + "demux_real: failed to allocate the audio frame buffer!\n"); + xprintf (this->stream->xine, XINE_VERBOSITY_LOG, "demux_real: buf type 0x%08x frame size %zu block align %d\n", stream->buf_type, stream->frame_size, stream->block_align); @@ -1373,6 +1377,11 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { int x; off_t pos; + if (!buffer) { + this->status = DEMUX_FINISHED; + return this->status; + } + switch (this->audio_stream->buf_type) { case BUF_AUDIO_28_8: for (x = 0; x < sph / 2; x++) { -- cgit v1.2.3 From 84fc2650fec6c339d5a5bac73466935bef7d6214 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Wed, 13 Aug 2008 17:33:05 +0100 Subject: Check for possible buffer overflow attempts in the Real demuxer. --- src/demuxers/demux_real.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index fdb913ef4..32b516537 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -1376,6 +1376,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { int spc = this->audio_stream->sub_packet_cnt; int x; off_t pos; + const size_t fs = this->audio_stream->frame_size; if (!buffer) { this->status = DEMUX_FINISHED; @@ -1386,7 +1387,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { case BUF_AUDIO_28_8: for (x = 0; x < sph / 2; x++) { pos = x * 2 * w + spc * cfs; - if(this->input->read(this->input, buffer + pos, cfs) < cfs) { + if(pos + cfs > fs || this->input->read(this->input, buffer + pos, cfs) < cfs) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read audio chunk\n"); @@ -1399,7 +1400,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { case BUF_AUDIO_ATRK: for (x = 0; x < w / sps; x++) { pos = sps * (sph * x + ((sph + 1) / 2) * (spc & 1) + (spc >> 1)); - if(this->input->read(this->input, buffer + pos, sps) < sps) { + if(pos + sps > fs || this->input->read(this->input, buffer + pos, sps) < sps) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read audio chunk\n"); @@ -1410,7 +1411,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { break; case BUF_AUDIO_SIPRO: pos = spc * w; - if(this->input->read(this->input, buffer + pos, w) < w) { + if(pos + w > fs || this->input->read(this->input, buffer + pos, w) < w) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "demux_real: failed to read audio chunk\n"); -- cgit v1.2.3 From ddaad16bd22f7e280e27fbb11e097a22a7268426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 28 May 2008 22:03:04 +0200 Subject: Fix exploitable heap buffer overflow in id3.c. For more information see xine bug #114. --- src/demuxers/id3.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/demuxers/id3.c b/src/demuxers/id3.c index d7d2c4725..3c03fdc68 100644 --- a/src/demuxers/id3.c +++ b/src/demuxers/id3.c @@ -275,15 +275,17 @@ static int id3v22_interp_frame(input_plugin_t *input, id3v22_frame_header_t *frame_header) { char *buf; int enc; + const size_t bufsize = frame_header->size +1; + if ( bufsize <= 2 ) /* frames has to be _at least_ 1 byte */ + return 0; - buf = malloc(frame_header->size + 1); + buf = malloc(bufsize); if (buf == NULL) { lprintf("malloc error"); return 0; } if (input->read (input, buf, frame_header->size) == frame_header->size) { - buf[frame_header->size] = 0; enc = buf[0]; if( enc >= ID3_ENCODING_COUNT ) enc = 0; @@ -469,8 +471,11 @@ static int id3v23_interp_frame(input_plugin_t *input, id3v23_frame_header_t *frame_header) { char *buf; int enc; - - buf = malloc(frame_header->size + 1); + const size_t bufsize = frame_header->size +1; + if ( bufsize <= 2 ) /* frames has to be _at least_ 1 byte */ + return 0; + + buf = malloc(bufsize); if (buf == NULL) { lprintf("malloc error"); return 0; @@ -720,8 +725,11 @@ static int id3v24_interp_frame(input_plugin_t *input, id3v24_frame_header_t *frame_header) { char *buf; int enc; - - buf = malloc(frame_header->size + 1); + const size_t bufsize = frame_header->size +1; + if ( bufsize <= 2 ) /* frames has to be _at least_ 1 byte */ + return 0; + + buf = malloc(bufsize); if (buf == NULL) { lprintf("malloc error"); return 0; -- cgit v1.2.3 From 7fa0f0692db43d238700950c62404d0e546883d1 Mon Sep 17 00:00:00 2001 From: Arnold Metselaar Date: Wed, 13 Aug 2008 17:33:05 +0100 Subject: add cdda_class_get_dir method to cdda plugin Date: Thu, 1 May 2008 21:05:55 +0200 This patch adds a cdda_class_get_dir method to the cdda input plugin. I can now add an audio cd to a play-list in Amarok. There may be small interruptions if another cd is playing though, so it would be desirable to lower the priority for access to the cd-drive by the get_dir function. --- src/input/input_cdda.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 7b2ebf660..eed7b1593 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -2493,6 +2493,134 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { return 1; } +static xine_mrl_t** cdda_class_get_dir(input_class_t *this_gen, + const char *filename, + int *num_files) { + cdda_input_class_t *this = (cdda_input_class_t *) this_gen; + cdda_input_plugin_t *ip; + cdrom_toc *toc; + char *base_mrl; + int len, frame; + const char * device; + int fd, i, err = -1; + int num_tracks; + + if (filename && *filename) { + device = filename; + if (strncasecmp(device,"cdda:/",6) == 0) { + device += 6; + while ('/' == *device) + device++; + device--; + } + } + else { + device = this->cdda_device; + } + lprintf("cdda_class_get_dir for >%s<\n", device); + + /* get the CD TOC */ + toc = init_cdrom_toc(); + + fd = -1; + + /* we create a new instance because getting a directory of a cd + * should not affect another cd that might be playing. */ + ip = (cdda_input_plugin_t *)xine_xmalloc(sizeof(cdda_input_plugin_t)); + ip->stream = NULL; + ip->fd = -1; + ip->net_fd = -1; + +#ifndef WIN32 + if( strchr(device,':') ) { + fd = network_connect(ip->stream, device); + if( fd != -1 ) { + err = network_read_cdrom_toc(ip->stream, fd, toc); + } + } +#endif + + if (fd == -1) { + if (cdda_open(ip, device, toc, &fd) == -1) { + lprintf("cdda_class_get_dir: opening >%s< failed %s\n", + device, strerror(errno)); + free(ip); + return NULL; + } + +#ifndef WIN32 + err = read_cdrom_toc(fd, toc); +#else + err = read_cdrom_toc(ip, toc); +#endif /* WIN32 */ + } + +#ifdef LOG + print_cdrom_toc(toc); +#endif + + cdda_close(ip); + + if ( err < 0 ) { + free(ip); + return NULL; + } + + num_tracks = toc->last_track - toc->first_track + 1; + + /* this could be done in read_cdrom_toc, but it seems other code doesn't use it */ + frame = toc->leadout_track.first_frame; + for ( i = num_tracks-1 ; i >= 0 ; i--) { + toc->toc_entries[i].total_frames = frame - toc->toc_entries[i].first_frame; + frame = toc->toc_entries[i].first_frame; + } + + if (toc->ignore_last_track) + num_tracks--; + + len = strlen(device) + 5; + base_mrl = xine_xmalloc(len+1); + sprintf(base_mrl, "cdda:%s", device); + + /* allocate space for the mrls's if needed. */ + if (num_tracks+1 > this->mrls_allocated_entries) { + this->mrls = realloc(this->mrls, (num_tracks+1) * sizeof(xine_mrl_t*)); + } + for (i = 0 ; i < num_tracks ; i++) { + if (i < this->mrls_allocated_entries) { + if (this->mrls[i]->origin) + free(this->mrls[i]->origin); + if (this->mrls[i]->mrl) + free(this->mrls[i]->mrl); + if (this->mrls[i]->link) { + free(this->mrls[i]->link); + this->mrls[i]->link = NULL; + } + } + else { + this->mrls[i] = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t)); + this->mrls[i]->link = NULL; + this->mrls_allocated_entries++; + } + this->mrls[i]->origin = strdup(base_mrl); + this->mrls[i]->mrl = xine_xmalloc(len+4); + sprintf( this->mrls[i]->mrl, "%s/%d", base_mrl, i+toc->first_track); + this->mrls[i]->type = mrl_cda | mrl_file_blockdev; + this->mrls[i]->size = toc->toc_entries[i].total_frames * CD_RAW_FRAME_SIZE; + } + /* Clean up */ + while(this->mrls_allocated_entries > num_tracks) { + MRL_ZERO(this->mrls[this->mrls_allocated_entries - 1]); + free(this->mrls[this->mrls_allocated_entries--]); + } + free_cdrom_toc(toc); + free(ip); + + this->mrls[num_tracks] = NULL; + *num_files = num_tracks; + return this->mrls; +} + static char ** cdda_class_get_autoplay_list (input_class_t *this_gen, int *num_files) { @@ -2717,8 +2845,7 @@ static void *init_plugin (xine_t *xine, void *data) { this->input_class.get_instance = cdda_class_get_instance; this->input_class.get_identifier = cdda_class_get_identifier; this->input_class.get_description = cdda_class_get_description; - /* this->input_class.get_dir = cdda_class_get_dir; */ - this->input_class.get_dir = NULL; + this->input_class.get_dir = cdda_class_get_dir; this->input_class.get_autoplay_list = cdda_class_get_autoplay_list; this->input_class.dispose = cdda_class_dispose; this->input_class.eject_media = cdda_class_eject_media; -- cgit v1.2.3 From 2c0dd5e118628a7cb2130ee89f78fe6e85240916 Mon Sep 17 00:00:00 2001 From: Arnold Metselaar Date: Wed, 13 Aug 2008 17:33:05 +0100 Subject: Improve parsing of cddb information Date: Thu, 1 May 2008 21:09:25 +0200 This patch improves the parsing of cddb information: * Disc and track titles can now contain '='. * If a track title is of the form / the meta-info will contain the track-artist rather than the disc-artist. I have tested these changes together with my get_dir patch with the sources from debian testing/security and both Amarok and gxine now show the right artists for tracks on a compilation album. --- src/input/input_cdda.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index eed7b1593..305ef6381 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -1475,7 +1475,7 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { if (sscanf(buffer, "DTITLE=%s", &buf[0]) == 1) { char *pt, *artist, *title; - pt = strrchr(buffer, '='); + pt = strchr(buffer, '='); if (pt) { pt++; @@ -1515,7 +1515,7 @@ static int _cdda_load_cached_cddb_infos(cdda_input_plugin_t *this) { else if (sscanf(buffer, "TTITLE%d=%s", &tnum, &buf[0]) == 2) { char *pt; - pt = strrchr(buffer, '='); + pt = strchr(buffer, '='); if (pt) pt++; if (this->cddb.track[tnum].title == NULL) @@ -2465,15 +2465,31 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { } if(this->cddb.track[this->track].title) { - lprintf("Track %d Title: %s\n", this->track+1, this->cddb.track[this->track].title); - - _x_meta_info_set_utf8(this->stream, XINE_META_INFO_TITLE, this->cddb.track[this->track].title); - } + /* Check for track 'titles' of the form / . */ + char *pt; + pt = strstr(this->cddb.track[this->track].title, " / "); + if (pt != NULL) { + char *track_artist; + track_artist = strdup(this->cddb.track[this->track].title); + track_artist[pt - this->cddb.track[this->track].title] = 0; + lprintf("Track %d Artist: %s\n", this->track+1, track_artist); + + _x_meta_info_set_utf8(this->stream, XINE_META_INFO_ARTIST, track_artist); + free(track_artist); + pt += 3; + } + else { + if(this->cddb.disc_artist) { + lprintf("Disc Artist: %s\n", this->cddb.disc_artist); + + _x_meta_info_set_utf8(this->stream, XINE_META_INFO_ARTIST, this->cddb.disc_artist); + } - if(this->cddb.disc_artist) { - lprintf("Disc Artist: %s\n", this->cddb.disc_artist); + pt = this->cddb.track[this->track].title; + } + lprintf("Track %d Title: %s\n", this->track+1, pt); - _x_meta_info_set_utf8(this->stream, XINE_META_INFO_ARTIST, this->cddb.disc_artist); + _x_meta_info_set_utf8(this->stream, XINE_META_INFO_TITLE, pt); } if(this->cddb.disc_category) { -- cgit v1.2.3