1 /* { dg-do compile } */
2 /* { dg-options "-funsafe-loop-optimizations -ftree-vrp" } */
4 typedef int FLAC__int32
;
5 typedef int FLAC__bool
;
6 typedef struct { } FLAC__Subframe
;
7 typedef enum { FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT
= 0, FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE
= 1, FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE
= 2, FLAC__CHANNEL_ASSIGNMENT_MID_SIDE
= 3 } FLAC__ChannelAssignment
;
9 struct FLAC__StreamEncoderProtected
*protected_
;
10 struct FLAC__StreamEncoderPrivate
*private_
;
11 } FLAC__StreamEncoder
;
12 typedef struct FLAC__StreamEncoderProtected
{
13 FLAC__bool loose_mid_side_stereo
;
16 } FLAC__StreamEncoderProtected
;
17 typedef struct FLAC__StreamEncoderPrivate
{
18 FLAC__int32
*integer_signal
[(8u)];
19 FLAC__Subframe subframe_workspace_mid_side
[2][2];
20 unsigned best_subframe_mid_side
[2];
21 unsigned loose_mid_side_stereo_frame_count
;
22 } FLAC__StreamEncoderPrivate
;
23 static void get_wasted_bits_(FLAC__int32 signal
[], unsigned samples
)
27 for(i
= 0; i
< samples
&& !(x
&1); i
++)
30 FLAC__Subframe
* process_subframes_(FLAC__StreamEncoder
*encoder
, unsigned *bits
)
33 FLAC__Subframe
*left_subframe
= 0;
34 FLAC__ChannelAssignment channel_assignment
;
35 for(channel
= 0; channel
< encoder
->protected_
->channels
; channel
++)
36 get_wasted_bits_(encoder
->private_
->integer_signal
[channel
], encoder
->protected_
->blocksize
);
37 if(encoder
->protected_
->loose_mid_side_stereo
&& encoder
->private_
->loose_mid_side_stereo_frame_count
> 0)
38 channel_assignment
= FLAC__CHANNEL_ASSIGNMENT_MID_SIDE
;
40 FLAC__ChannelAssignment ca
= (FLAC__ChannelAssignment
)1;
41 unsigned min_bits
= bits
[0];
42 for(channel_assignment
= (FLAC__ChannelAssignment
)0; (int)ca
<= 3; ca
= (FLAC__ChannelAssignment
)((int)ca
+ 1))
43 if(bits
[ca
] < min_bits
)
44 channel_assignment
= ca
;
46 switch(channel_assignment
) {
47 case FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT
:
48 case FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE
:
49 case FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE
:
50 case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE
:
51 left_subframe
= &encoder
->private_
->subframe_workspace_mid_side
[0][encoder
->private_
->best_subframe_mid_side
[0]];