Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: source/patched-ffmpeg-mt/libavcodec/mpegaudiodec.c

Issue 2850032: ffmpeg update to june 23 version which fixes mp4 crash on still frames with 3... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * MPEG Audio decoder 2 * MPEG Audio decoder
3 * Copyright (c) 2001, 2002 Fabrice Bellard 3 * Copyright (c) 2001, 2002 Fabrice Bellard
4 * 4 *
5 * This file is part of FFmpeg. 5 * This file is part of FFmpeg.
6 * 6 *
7 * FFmpeg is free software; you can redistribute it and/or 7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version. 10 * version 2.1 of the License, or (at your option) any later version.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 /****************/ 63 /****************/
64 64
65 #define HEADER_SIZE 4 65 #define HEADER_SIZE 4
66 66
67 #include "mpegaudiodata.h" 67 #include "mpegaudiodata.h"
68 #include "mpegaudiodectab.h" 68 #include "mpegaudiodectab.h"
69 69
70 static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g); 70 static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g);
71 static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g); 71 static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g);
72 static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
73 int *dither_state, OUT_INT *samples, int incr);
72 74
73 /* vlc structure for decoding layer 3 huffman tables */ 75 /* vlc structure for decoding layer 3 huffman tables */
74 static VLC huff_vlc[16]; 76 static VLC huff_vlc[16];
75 static VLC_TYPE huff_vlc_tables[ 77 static VLC_TYPE huff_vlc_tables[
76 0+128+128+128+130+128+154+166+ 78 0+128+128+128+130+128+154+166+
77 142+204+190+170+542+460+662+414 79 142+204+190+170+542+460+662+414
78 ][2]; 80 ][2];
79 static const int huff_vlc_tables_sizes[16] = { 81 static const int huff_vlc_tables_sizes[16] = {
80 0, 128, 128, 128, 130, 128, 154, 166, 82 0, 128, 128, 128, 130, 128, 154, 166,
81 142, 204, 190, 170, 542, 460, 662, 414 83 142, 204, 190, 170, 542, 460, 662, 414
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 300 }
299 #endif 301 #endif
300 302
301 static av_cold int decode_init(AVCodecContext * avctx) 303 static av_cold int decode_init(AVCodecContext * avctx)
302 { 304 {
303 MPADecodeContext *s = avctx->priv_data; 305 MPADecodeContext *s = avctx->priv_data;
304 static int init=0; 306 static int init=0;
305 int i, j, k; 307 int i, j, k;
306 308
307 s->avctx = avctx; 309 s->avctx = avctx;
310 s->apply_window_mp3 = apply_window_mp3_c;
308 311
309 avctx->sample_fmt= OUT_FMT; 312 avctx->sample_fmt= OUT_FMT;
310 s->error_recognition= avctx->error_recognition; 313 s->error_recognition= avctx->error_recognition;
311 314
312 if (!init && !avctx->parse_only) { 315 if (!init && !avctx->parse_only) {
313 int offset; 316 int offset;
314 317
315 /* scale factors table for layer 1/2 */ 318 /* scale factors table for layer 1/2 */
316 for(i=0;i<64;i++) { 319 for(i=0;i<64;i++) {
317 int shift, mod; 320 int shift, mod;
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS); 832 v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
830 #endif 833 #endif
831 window[i] = v; 834 window[i] = v;
832 if ((i & 63) != 0) 835 if ((i & 63) != 0)
833 v = -v; 836 v = -v;
834 if (i != 0) 837 if (i != 0)
835 window[512 - i] = v; 838 window[512 - i] = v;
836 } 839 }
837 } 840 }
838 841
839 /* 32 sub band synthesis filter. Input: 32 sub band samples, Output: 842 static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
840 32 samples. */ 843 int *dither_state, OUT_INT *samples, int incr)
841 /* XXX: optimize by avoiding ring buffer usage */
842 void RENAME(ff_mpa_synth_filter)(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
843 MPA_INT *window, int *dither_state,
844 OUT_INT *samples, int incr,
845 INTFLOAT sb_samples[SBLIMIT])
846 { 844 {
847 register MPA_INT *synth_buf;
848 register const MPA_INT *w, *w2, *p; 845 register const MPA_INT *w, *w2, *p;
849 int j, offset; 846 int j;
850 OUT_INT *samples2; 847 OUT_INT *samples2;
851 #if CONFIG_FLOAT 848 #if CONFIG_FLOAT
852 float sum, sum2; 849 float sum, sum2;
853 #elif FRAC_BITS <= 15 850 #elif FRAC_BITS <= 15
854 int32_t tmp[32];
855 int sum, sum2; 851 int sum, sum2;
856 #else 852 #else
857 int64_t sum, sum2; 853 int64_t sum, sum2;
858 #endif 854 #endif
859 855
860 offset = *synth_buf_offset;
861 synth_buf = synth_buf_ptr + offset;
862
863 #if FRAC_BITS <= 15 && !CONFIG_FLOAT
864 dct32(tmp, sb_samples);
865 for(j=0;j<32;j++) {
866 /* NOTE: can cause a loss in precision if very high amplitude
867 sound */
868 synth_buf[j] = av_clip_int16(tmp[j]);
869 }
870 #else
871 dct32(synth_buf, sb_samples);
872 #endif
873
874 /* copy to avoid wrap */ 856 /* copy to avoid wrap */
875 memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf)); 857 memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));
876 858
877 samples2 = samples + 31 * incr; 859 samples2 = samples + 31 * incr;
878 w = window; 860 w = window;
879 w2 = window + 31; 861 w2 = window + 31;
880 862
881 sum = *dither_state; 863 sum = *dither_state;
882 p = synth_buf + 16; 864 p = synth_buf + 16;
883 SUM8(MACS, sum, w, p); 865 SUM8(MACS, sum, w, p);
(...skipping 18 matching lines...) Expand all
902 *samples2 = round_sample(&sum); 884 *samples2 = round_sample(&sum);
903 samples2 -= incr; 885 samples2 -= incr;
904 w++; 886 w++;
905 w2--; 887 w2--;
906 } 888 }
907 889
908 p = synth_buf + 32; 890 p = synth_buf + 32;
909 SUM8(MLSS, sum, w + 32, p); 891 SUM8(MLSS, sum, w + 32, p);
910 *samples = round_sample(&sum); 892 *samples = round_sample(&sum);
911 *dither_state= sum; 893 *dither_state= sum;
894 }
895
896
897 /* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
898 32 samples. */
899 /* XXX: optimize by avoiding ring buffer usage */
900 #if CONFIG_FLOAT
901 void ff_mpa_synth_filter_float(MPADecodeContext *s, float *synth_buf_ptr,
902 int *synth_buf_offset,
903 float *window, int *dither_state,
904 float *samples, int incr,
905 float sb_samples[SBLIMIT])
906 {
907 float *synth_buf;
908 int offset;
909
910 offset = *synth_buf_offset;
911 synth_buf = synth_buf_ptr + offset;
912
913 dct32(synth_buf, sb_samples);
914 s->apply_window_mp3(synth_buf, window, dither_state, samples, incr);
912 915
913 offset = (offset - 32) & 511; 916 offset = (offset - 32) & 511;
914 *synth_buf_offset = offset; 917 *synth_buf_offset = offset;
915 } 918 }
919 #else
920 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
921 MPA_INT *window, int *dither_state,
922 OUT_INT *samples, int incr,
923 INTFLOAT sb_samples[SBLIMIT])
924 {
925 register MPA_INT *synth_buf;
926 int offset;
927 #if FRAC_BITS <= 15
928 int32_t tmp[32];
929 int j;
930 #endif
931
932 offset = *synth_buf_offset;
933 synth_buf = synth_buf_ptr + offset;
934
935 #if FRAC_BITS <= 15 && !CONFIG_FLOAT
936 dct32(tmp, sb_samples);
937 for(j=0;j<32;j++) {
938 /* NOTE: can cause a loss in precision if very high amplitude
939 sound */
940 synth_buf[j] = av_clip_int16(tmp[j]);
941 }
942 #else
943 dct32(synth_buf, sb_samples);
944 #endif
945
946 apply_window_mp3_c(synth_buf, window, dither_state, samples, incr);
947
948 offset = (offset - 32) & 511;
949 *synth_buf_offset = offset;
950 }
951 #endif
916 952
917 #define C3 FIXHR(0.86602540378443864676/2) 953 #define C3 FIXHR(0.86602540378443864676/2)
918 954
919 /* 0.5 / cos(pi*(2*i+1)/36) */ 955 /* 0.5 / cos(pi*(2*i+1)/36) */
920 static const INTFLOAT icos36[9] = { 956 static const INTFLOAT icos36[9] = {
921 FIXR(0.50190991877167369479), 957 FIXR(0.50190991877167369479),
922 FIXR(0.51763809020504152469), //0 958 FIXR(0.51763809020504152469), //0
923 FIXR(0.55168895948124587824), 959 FIXR(0.55168895948124587824),
924 FIXR(0.61038729438072803416), 960 FIXR(0.61038729438072803416),
925 FIXR(0.70710678118654752439), //1 961 FIXR(0.70710678118654752439), //1
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_ SIZE - i, i); 2256 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_ SIZE - i, i);
2221 s->last_buf_size += i; 2257 s->last_buf_size += i;
2222 2258
2223 break; 2259 break;
2224 } 2260 }
2225 2261
2226 /* apply the synthesis filter */ 2262 /* apply the synthesis filter */
2227 for(ch=0;ch<s->nb_channels;ch++) { 2263 for(ch=0;ch<s->nb_channels;ch++) {
2228 samples_ptr = samples + ch; 2264 samples_ptr = samples + ch;
2229 for(i=0;i<nb_frames;i++) { 2265 for(i=0;i<nb_frames;i++) {
2230 RENAME(ff_mpa_synth_filter)(s->synth_buf[ch], &(s->synth_buf_offset[ ch]), 2266 RENAME(ff_mpa_synth_filter)(
2267 #if CONFIG_FLOAT
2268 s,
2269 #endif
2270 s->synth_buf[ch], &(s->synth_buf_offset[ch]),
2231 RENAME(ff_mpa_synth_window), &s->dither_state, 2271 RENAME(ff_mpa_synth_window), &s->dither_state,
2232 samples_ptr, s->nb_channels, 2272 samples_ptr, s->nb_channels,
2233 s->sb_samples[ch][i]); 2273 s->sb_samples[ch][i]);
2234 samples_ptr += 32 * s->nb_channels; 2274 samples_ptr += 32 * s->nb_channels;
2235 } 2275 }
2236 } 2276 }
2237 2277
2238 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; 2278 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
2239 } 2279 }
2240 2280
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 sizeof(MP3On4DecodeContext), 2629 sizeof(MP3On4DecodeContext),
2590 decode_init_mp3on4, 2630 decode_init_mp3on4,
2591 NULL, 2631 NULL,
2592 decode_close_mp3on4, 2632 decode_close_mp3on4,
2593 decode_frame_mp3on4, 2633 decode_frame_mp3on4,
2594 .flush= flush, 2634 .flush= flush,
2595 .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"), 2635 .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"),
2596 }; 2636 };
2597 #endif 2637 #endif
2598 #endif 2638 #endif
OLDNEW
« no previous file with comments | « source/patched-ffmpeg-mt/libavcodec/mpegaudio.h ('k') | source/patched-ffmpeg-mt/libavcodec/nellymoserdec.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698