GSoC/GCI Archive
Google Code-in 2011 VideoLAN

Code Cleanup

completed by: Nathan

mentors: Luca Barbato

Libav has a defined coding style, sadly ancient code doesn't adhere to it, your task is to pick a file, reformat it properly and send an patch to the mailing list (also upload it here).

 

Coding style in short:

Keep the line within the 80col.

 

function parameters can be split over more line if they don't fit, and the bracket opening the function body should stay alone in a new line:

 Example

void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h,

                              int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8){

Become:

void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, 

                              uint8_t **block, int b_w, int b_h, int src_x, 

                              int src_y, int src_stride, slice_buffer * sb, 

                              int add, uint8_t *dst8)
{

if, while, do, for should have a space between the keyword and the parenthesis. The brackets to mark a the block could stay in the same line of the condition, separated by a space from the closing parenthesis. The operators +, -, should have a space before and after them, *, / ^ and & could have one, = MUST have a space before and one after

    for(y=0; y>1);

        const uint8_t *obmc3= obmc1+obmc_stride*(obmc_stride>>1);

        const uint8_t *obmc4= obmc3+(obmc_stride>>1);

for (y = 0; y < b_h; y++) {
        const uint8_t *obmc1 = obmc  + y*obmc_stride;

        const uint8_t *obmc2 = obmc1 + (obmc_stride>>1);

        const uint8_t *obmc3 = obmc1 + obmc_stride*(obmc_stride>>1);

        const uint8_t *obmc4 = obmc3 + (obmc_stride>>1);

Ask on #libav on irc.freenode.net for help and guidance. Every file around 500 lines cleaned up grants an easy task.