Mercurial > libavcodec.hg
comparison ac3dec.c @ 6869:59ae0494b656 libavcodec
add checks for missing information in the first block
author | jbr |
---|---|
date | Sun, 25 May 2008 15:34:48 +0000 |
parents | 5387096bf92a |
children | dc6c9f74f2c1 |
comparison
equal
deleted
inserted
replaced
6868:5387096bf92a | 6869:59ae0494b656 |
---|---|
851 } else { | 851 } else { |
852 /* coupling not in use */ | 852 /* coupling not in use */ |
853 for (ch = 1; ch <= fbw_channels; ch++) | 853 for (ch = 1; ch <= fbw_channels; ch++) |
854 s->channel_in_cpl[ch] = 0; | 854 s->channel_in_cpl[ch] = 0; |
855 } | 855 } |
856 } else if (!blk) { | |
857 av_log(s->avctx, AV_LOG_ERROR, "new coupling strategy must be present in block 0\n"); | |
858 return -1; | |
856 } | 859 } |
857 | 860 |
858 /* coupling coordinates */ | 861 /* coupling coordinates */ |
859 if (s->cpl_in_use) { | 862 if (s->cpl_in_use) { |
860 int cpl_coords_exist = 0; | 863 int cpl_coords_exist = 0; |
872 s->cpl_coords[ch][bnd] = cpl_coord_mant << 22; | 875 s->cpl_coords[ch][bnd] = cpl_coord_mant << 22; |
873 else | 876 else |
874 s->cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21; | 877 s->cpl_coords[ch][bnd] = (cpl_coord_mant + 16) << 21; |
875 s->cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord); | 878 s->cpl_coords[ch][bnd] >>= (cpl_coord_exp + master_cpl_coord); |
876 } | 879 } |
880 } else if (!blk) { | |
881 av_log(s->avctx, AV_LOG_ERROR, "new coupling coordinates must be present in block 0\n"); | |
882 return -1; | |
877 } | 883 } |
878 } | 884 } |
879 } | 885 } |
880 /* phase flags */ | 886 /* phase flags */ |
881 if (channel_mode == AC3_CHMODE_STEREO && cpl_coords_exist) { | 887 if (channel_mode == AC3_CHMODE_STEREO && cpl_coords_exist) { |
891 s->num_rematrixing_bands = 4; | 897 s->num_rematrixing_bands = 4; |
892 if(s->cpl_in_use && s->start_freq[CPL_CH] <= 61) | 898 if(s->cpl_in_use && s->start_freq[CPL_CH] <= 61) |
893 s->num_rematrixing_bands -= 1 + (s->start_freq[CPL_CH] == 37); | 899 s->num_rematrixing_bands -= 1 + (s->start_freq[CPL_CH] == 37); |
894 for(bnd=0; bnd<s->num_rematrixing_bands; bnd++) | 900 for(bnd=0; bnd<s->num_rematrixing_bands; bnd++) |
895 s->rematrixing_flags[bnd] = get_bits1(gbc); | 901 s->rematrixing_flags[bnd] = get_bits1(gbc); |
902 } else if (!blk) { | |
903 av_log(s->avctx, AV_LOG_ERROR, "new rematrixing strategy must be present in block 0\n"); | |
904 return -1; | |
896 } | 905 } |
897 } | 906 } |
898 | 907 |
899 /* exponent strategies for each channel */ | 908 /* exponent strategies for each channel */ |
900 s->exp_strategy[CPL_CH] = EXP_REUSE; | 909 s->exp_strategy[CPL_CH] = EXP_REUSE; |
957 s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)]; | 966 s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)]; |
958 s->bit_alloc_params.floor = ff_ac3_floor_tab[get_bits(gbc, 3)]; | 967 s->bit_alloc_params.floor = ff_ac3_floor_tab[get_bits(gbc, 3)]; |
959 for(ch=!s->cpl_in_use; ch<=s->channels; ch++) { | 968 for(ch=!s->cpl_in_use; ch<=s->channels; ch++) { |
960 bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); | 969 bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); |
961 } | 970 } |
971 } else if (!blk) { | |
972 av_log(s->avctx, AV_LOG_ERROR, "new bit allocation info must be present in block 0\n"); | |
973 return -1; | |
962 } | 974 } |
963 | 975 |
964 /* signal-to-noise ratio offsets and fast gains (signal-to-mask ratios) */ | 976 /* signal-to-noise ratio offsets and fast gains (signal-to-mask ratios) */ |
965 if (get_bits1(gbc)) { | 977 if (get_bits1(gbc)) { |
966 int csnr; | 978 int csnr; |
968 for (ch = !s->cpl_in_use; ch <= s->channels; ch++) { /* snr offset and fast gain */ | 980 for (ch = !s->cpl_in_use; ch <= s->channels; ch++) { /* snr offset and fast gain */ |
969 s->snr_offset[ch] = (csnr + get_bits(gbc, 4)) << 2; | 981 s->snr_offset[ch] = (csnr + get_bits(gbc, 4)) << 2; |
970 s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)]; | 982 s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)]; |
971 } | 983 } |
972 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); | 984 memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); |
985 } else if (!blk) { | |
986 av_log(s->avctx, AV_LOG_ERROR, "new snr offsets must be present in block 0\n"); | |
987 return -1; | |
973 } | 988 } |
974 | 989 |
975 /* coupling leak information */ | 990 /* coupling leak information */ |
976 if (s->cpl_in_use && get_bits1(gbc)) { | 991 if (s->cpl_in_use && get_bits1(gbc)) { |
977 s->bit_alloc_params.cpl_fast_leak = get_bits(gbc, 3); | 992 s->bit_alloc_params.cpl_fast_leak = get_bits(gbc, 3); |
978 s->bit_alloc_params.cpl_slow_leak = get_bits(gbc, 3); | 993 s->bit_alloc_params.cpl_slow_leak = get_bits(gbc, 3); |
979 bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2); | 994 bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2); |
995 } else if (!blk) { | |
996 av_log(s->avctx, AV_LOG_ERROR, "new coupling leak info must be present in block 0\n"); | |
997 return -1; | |
980 } | 998 } |
981 | 999 |
982 /* delta bit allocation information */ | 1000 /* delta bit allocation information */ |
983 if (get_bits1(gbc)) { | 1001 if (get_bits1(gbc)) { |
984 /* delta bit allocation exists (strategy) */ | 1002 /* delta bit allocation exists (strategy) */ |