| @@ -30,8 +30,8 @@ · 29 unmodified lines |
| 30 | 30 | |
| 31 | 31 | static double get(const uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f){ |
| 32 | 32 | const uint8_t *p; |
| 33 | | − if(f>=0x100){ |
| 34 | | − f&=0xFF; |
| 33 | + if(av_sample_fmt_is_planar(f)){ |
| 34 | + f= av_get_alt_sample_fmt(f, 0); |
| 35 | 35 | p= a[ch]; |
| 36 | 36 | }else{ |
| 37 | 37 | p= a[0]; |
| @@ -50,8 +50,8 @@ static double get(const uint8_t *a[], int ch, int index, int ch_count, enum AVSa · 12 unmodified lines |
| 50 | 50 | |
| 51 | 51 | static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v){ |
| 52 | 52 | uint8_t *p; |
| 53 | | − if(f>=0x100){ |
| 54 | | − f&=0xFF; |
| 53 | + if(av_sample_fmt_is_planar(f)){ |
| 54 | + f= av_get_alt_sample_fmt(f, 0); |
| 55 | 55 | p= a[ch]; |
| 56 | 56 | }else{ |
| 57 | 57 | p= a[0]; |
| @@ -86,7 +86,7 @@ AV_CH_LAYOUT_7POINT1_WIDE , · 28 unmodified lines |
| 86 | 86 | }; |
| 87 | 87 | |
| 88 | 88 | static void setup_array(uint8_t *out[SWR_CH_MAX], uint8_t *in, enum AVSampleFormat format, int samples){ |
| 89 | | − if(format >= 0x100){ |
| 89 | + if(av_sample_fmt_is_planar(format)){ |
| 90 | 90 | int i; |
| 91 | 91 | int plane_size= av_get_bytes_per_sample(format&0xFF)*samples; |
| 92 | 92 | format&=0xFF; |
| @@ -109,7 +109,6 @@ int main(int argc, char **argv){ · 16 unmodified lines |
| 109 | 109 | uint8_t *ain[SWR_CH_MAX]; |
| 110 | 110 | uint8_t *aout[SWR_CH_MAX]; |
| 111 | 111 | uint8_t *amid[SWR_CH_MAX]; |
| 112 | | − int planar_in=256, planar_out=256; |
| 113 | 112 | |
| 114 | 113 | struct SwrContext * forw_ctx= NULL; |
| 115 | 114 | struct SwrContext *backw_ctx= NULL; |
| @@ -130,11 +129,11 @@ int main(int argc, char **argv){ · 14 unmodified lines |
| 130 | 129 | in_ch_count, out_ch_count, |
| 131 | 130 | in_sample_rate, out_sample_rate, |
| 132 | 131 | av_get_sample_fmt_name(in_sample_fmt), av_get_sample_fmt_name(out_sample_fmt)); |
| 133 | | − forw_ctx = swr_alloc_set_opts(forw_ctx, out_ch_layout, out_sample_fmt+planar_out, out_sample_rate, |
| 134 | | − in_ch_layout, in_sample_fmt+planar_in , in_sample_rate, |
| 132 | + forw_ctx = swr_alloc_set_opts(forw_ctx, out_ch_layout, av_get_alt_sample_fmt(out_sample_fmt, 1), out_sample_rate, |
| 133 | + in_ch_layout, av_get_alt_sample_fmt( in_sample_fmt, 1), in_sample_rate, |
| 135 | 134 | 0, 0); |
| 136 | 135 | backw_ctx = swr_alloc_set_opts(backw_ctx, in_ch_layout, in_sample_fmt, in_sample_rate, |
| 137 | | − out_ch_layout, out_sample_fmt+planar_out, out_sample_rate, |
| 136 | + out_ch_layout, av_get_alt_sample_fmt(out_sample_fmt, 1), out_sample_rate, |
| 138 | 137 | 0, 0); |
| 139 | 138 | if(swr_init( forw_ctx) < 0) |
| 140 | 139 | fprintf(stderr, "swr_init(->) failed\n"); |
| @@ -145,12 +144,12 @@ int main(int argc, char **argv){ · 4 unmodified lines |
| 145 | 144 | if(!backw_ctx) |
| 146 | 145 | fprintf(stderr, "Failed to init backw_ctx\n"); |
| 147 | 146 | //FIXME test planar |
| 148 | | − setup_array(ain , array_in , in_sample_fmt+planar_in , SAMPLES); |
| 149 | | − setup_array(amid, array_mid, out_sample_fmt+planar_out, 3*SAMPLES); |
| 147 | + setup_array(ain , array_in , av_get_alt_sample_fmt( in_sample_fmt, 1), SAMPLES); |
| 148 | + setup_array(amid, array_mid, av_get_alt_sample_fmt(out_sample_fmt, 1), 3*SAMPLES); |
| 150 | 149 | setup_array(aout, array_out, in_sample_fmt , SAMPLES); |
| 151 | 150 | for(ch=0; ch<in_ch_count; ch++){ |
| 152 | 151 | for(i=0; i<SAMPLES; i++) |
| 153 | | − set(ain, ch, i, in_ch_count, in_sample_fmt+planar_in, sin(i*i*3/SAMPLES)); |
| 152 | + set(ain, ch, i, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1), sin(i*i*3/SAMPLES)); |
| 154 | 153 | } |
| 155 | 154 | mid_count= swr_convert(forw_ctx, amid, 3*SAMPLES, ain, SAMPLES); |
| 156 | 155 | out_count= swr_convert(backw_ctx,aout, SAMPLES, amid, mid_count); |
| @@ -163,7 +162,7 @@ int main(int argc, char **argv){ · 6 unmodified lines |
| 163 | 162 | double sum_bb= 0; |
| 164 | 163 | double sum_ab= 0; |
| 165 | 164 | for(i=0; i<out_count; i++){ |
| 166 | | − double a= get(ain , ch, i, in_ch_count, in_sample_fmt+planar_in); |
| 165 | + double a= get(ain , ch, i, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1)); |
| 167 | 166 | double b= get(aout, ch, i, in_ch_count, in_sample_fmt); |
| 168 | 167 | sum_a += a; |
| 169 | 168 | sum_b += b; |
| @@ -188,7 +187,7 @@ int main(int argc, char **argv){ · 18 unmodified lines |
| 188 | 187 | double sum_bb= 0; |
| 189 | 188 | double sum_ab= 0; |
| 190 | 189 | for(i=0; i<flush_count; i++){ |
| 191 | | − double a= get(ain , ch, i+out_count, in_ch_count, in_sample_fmt+planar_in); |
| 190 | + double a= get(ain , ch, i+out_count, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1)); |
| 192 | 191 | double b= get(aout, ch, i, in_ch_count, in_sample_fmt); |
| 193 | 192 | sum_a += a; |
| 194 | 193 | sum_b += b; |