+ bool b_compatible = true;
+ if( p_pic->p[0].i_pitch / p_pic->p[0].i_pixel_pitch < i_width ||
+ p_pic->p[0].i_lines < i_height )
+ b_compatible = false;
+ for( int i = 0; i < p_pic->i_planes && b_compatible; i++ )
+ {
+ const unsigned i_align = i == 0 ? 16 : 8;
+ if( p_pic->p[i].i_pitch % i_align )
+ b_compatible = false;
+ if( (intptr_t)p_pic->p[i].p_pixels % i_align )
+ b_compatible = false;
+ }
+ if( !b_compatible )
+ {
+ decoder_DeletePicture( p_dec, p_pic );
+ return avcodec_default_get_buffer( p_context, p_ff_pic );
+ }