On Sat, Jan 07, 2012 at 11:35:41PM -0600, Daniel Huang wrote:
>
> From d154900f8cafb0b3132b30f38dc5586a4ed6412f Mon Sep 17 00:00:00 2001
> From: Daniel Huang <[email protected]>
> Date: Sat, 7 Jan 2012 23:25:25 -0600
> Subject: [PATCH] K&R formatting cosmetics
We are getting close, I think the next round will be fit for pushing.
But please finally change the log message to the following:
mjpegdec: K&R formatting cosmetics
> --- a/libavcodec/mjpegdec.c
> +++ b/libavcodec/mjpegdec.c
> @@ -89,10 +92,10 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
> dsputil_init(&s->dsp, avctx);
> ff_init_scantable(s->dsp.idct_permutation, &s->scantable,
> ff_zigzag_direct);
> s->buffer_size = 0;
> - s->buffer = NULL;
> - s->start_code = -1;
> + s->buffer = NULL;
> + s->start_code = -1;
> s->first_picture = 1;
> - s->org_height = avctx->coded_height;
> + s->org_height = avctx->coded_height;
Align the =
> @@ -140,19 +141,19 @@ int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
>
> - //XXX FIXME finetune, and perhaps add dc too
> - s->qscale[index]= FFMAX(
> - s->quant_matrixes[index][s->scantable.permutated[1]],
> - s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
> - av_log(s->avctx, AV_LOG_DEBUG, "qscale[%d]: %d\n", index,
> s->qscale[index]);
> + // XXX FIXME finetune, and perhaps add dc too
> + s->qscale[index] = FFMAX
> +
> (s->quant_matrixes[index][s->scantable.permutated[1]],
> +
> s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
We never break lines like this. Just let the lines be long.
> @@ -215,40 +216,43 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> s->nb_components = nb_components;
> s->h_max = 1;
> s->v_max = 1;
Align the =
> - for(i=0;i<nb_components;i++) {
> + for (i = 0; i < nb_components; i++) {
> /* component id */
> s->component_id[i] = get_bits(&s->gb, 8) - 1;
> s->h_count[i] = get_bits(&s->gb, 4);
ditto
> @@ -261,23 +265,24 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
>
> - s->width = width;
> + s->width = width;
> s->height = height;
> s->interlaced = 0;
ditto
> @@ -285,7 +290,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> if (s->first_picture &&
> s->org_height != 0 &&
> s->height < ((s->org_height * 3) / 4)) {
> - s->interlaced = 1;
> + s->interlaced = 1;
> s->bottom_field = s->interlace_polarity;
> s->picture_ptr->interlaced_frame = 1;
> s->picture_ptr->top_field_first = !s->interlace_polarity;
more
> @@ -338,46 +343,44 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
>
> -// printf("%d %d %d %d %d %d\n", s->width, s->height, s->linesize[0],
> s->linesize[1], s->interlaced, s->avctx->height);
> +// printf("%d %d %d %d %d %d\n",
> +// s->width, s->height, s->linesize[0], s->linesize[1],
> s->interlaced, s->avctx->height);
nit: This line is a tad long.
> /* totally blank picture as progressive JPEG will only add details to it
> */
> - if(s->progressive){
> - int bw = (width + s->h_max*8-1) / (s->h_max*8);
> - int bh = (height + s->v_max*8-1) / (s->v_max*8);
> - for(i=0; i<s->nb_components; i++) {
> + if (s->progressive) {
> + int bw = (width + s->h_max * 8 - 1) / (s->h_max * 8);
> + int bh = (height + s->v_max * 8 - 1) / (s->v_max * 8);
> + for (i = 0; i < s->nb_components; i++) {
> int size = bw * bh * s->h_count[i] * s->v_count[i];
> av_freep(&s->blocks[i]);
> av_freep(&s->last_nnz[i]);
> - s->blocks[i] = av_malloc(size * sizeof(**s->blocks));
> + s->blocks[i] = av_malloc(size * sizeof(**s->blocks));
> s->last_nnz[i] = av_mallocz(size * sizeof(**s->last_nnz));
> s->block_stride[i] = bw * s->h_count[i];
Align the =.
> @@ -530,52 +532,53 @@ static int decode_block_progressive(MJpegDecodeContext
> *s, DCTELEM *block, uint8
>
> -#define REFINE_BIT(j) {\
> - UPDATE_CACHE(re, &s->gb);\
> - sign = block[j]>>15;\
> - block[j] += SHOW_UBITS(re, &s->gb, 1) * ((quant_matrix[j]^sign)-sign) <<
> Al;\
> - LAST_SKIP_BITS(re, &s->gb, 1);\
> +#define REFINE_BIT(j) { \
> + UPDATE_CACHE(re, &s->gb); \
> + sign = block[j] >> 15; \
> + block[j] += SHOW_UBITS(re, &s->gb, 1) * \
> + ((quant_matrix[j]^sign)-sign) << Al; \
> + LAST_SKIP_BITS(re, &s->gb, 1); \
Indent the SHOW_UBITS macro like a function, add spaces around ^ and -.
> @@ -669,40 +675,43 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s,
> int predictor, int point
>
> - if(s->rct){
> - for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
> - ptr[4*mb_x+1] = buffer[mb_x][0] - ((buffer[mb_x][1] +
> buffer[mb_x][2] - 0x200)>>2);
> - ptr[4*mb_x+0] = buffer[mb_x][1] + ptr[4*mb_x+1];
> - ptr[4*mb_x+2] = buffer[mb_x][2] + ptr[4*mb_x+1];
> + if (s->rct) {
> + for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
> + ptr[4 * mb_x + 1] = buffer[mb_x][0] - ((buffer[mb_x][1] +
> + buffer[mb_x][2] - 0x200) >> 2);
> + ptr[4 * mb_x + 0] = buffer[mb_x][1] + ptr[4 * mb_x + 1];
> + ptr[4 * mb_x + 2] = buffer[mb_x][2] + ptr[4 * mb_x + 1];
Keep the long line.
> @@ -751,14 +759,15 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s,
> int predictor, int point
>
> - ptr = s->picture_ptr->data[c] + (linesize * (v *
> mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
> - PREDICT(pred, ptr[-linesize-1], ptr[-linesize],
> ptr[-1], predictor);
> + ptr = s->picture_ptr->data[c] + (linesize * (v *
> mb_y + y)) +
> + (h * mb_x + x); // FIXME optimize this crap
> + PREDICT(pred, ptr[-linesize - 1], ptr[-linesize],
> ptr[-1], predictor);
Move the comment before the assignment.
> @@ -842,38 +855,42 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int
> nb_components, int Ah, i
>
> -// av_log(s->avctx, AV_LOG_DEBUG, "mb: %d %d
> processed\n", mb_y, mb_x);
> -//av_log(NULL, AV_LOG_DEBUG, "%d %d %d %d %d %d %d %d \n", mb_x, mb_y, x, y,
> c, s->bottom_field, (v * mb_y + y) * 8, (h * mb_x + x) * 8);
> +// av_log(s->avctx, AV_LOG_DEBUG, "mb: %d %d processed\n", mb_y,
> mb_x);
> +// av_log(NULL, AV_LOG_DEBUG, "%d %d %d %d %d %d %d %d \n",
> +// mb_x, mb_y, x, y, c, s->bottom_field, (v * mb_y + y) * 8,
> (h * mb_x + x) * 8);
> if (++x == h) {
> x = 0;
> y++;
I think the av_log calls are not at the right indentation level.
> @@ -904,61 +920,61 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int
> nb_components, int Ah, i
>
> - if(s->interlaced && s->bottom_field) {
> + if (s->interlaced && s->bottom_field) {
> int offset = linesize >> 1;
> data += offset;
> reference_data += offset;
> }
align
> - if(last_scan) {
> - if (copy_mb) {
> + if (last_scan) {
> + if (copy_mb)
> mjpeg_copy_block(ptr, reference_data + block_offset,
> linesize, s->avctx->lowres);
> - } else {
> - s->dsp.idct_put(ptr, linesize, *block);
> - ptr += 8 >> s->avctx->lowres;
> + else {
> + s->dsp.idct_put(ptr, linesize, *block);
> + ptr += 8 >> s->avctx->lowres;
> }
Keep the {} in this case.
> @@ -1211,13 +1226,11 @@ static int mjpeg_decode_app(MJpegDecodeContext *s)
>
> /* Apple MJPEG-A */
> - if ((s->start_code == APP1) && (len > (0x28 - 8)))
> - {
> - id = get_bits_long(&s->gb, 32);
> - id = av_be2ne32(id);
> + if ((s->start_code == APP1) && (len > (0x28 - 8))) {
> + id = get_bits_long(&s->gb, 32);
> + id = av_be2ne32(id);
> len -= 4;
> - if (id == AV_RL32("mjpg")) /* Apple MJPEG-A */
> - {
> + if (id == AV_RL32("mjpg")) /* Apple MJPEG-A */ {
Move the comment before the if.
> @@ -1246,34 +1259,30 @@ out:
> if (cbuf) {
> int i;
> for (i = 0; i < len - 2; i++)
> cbuf[i] = get_bits(&s->gb, 8);
> - if (i > 0 && cbuf[i-1] == '\n')
> - cbuf[i-1] = 0;
> + if (i > 0 && cbuf[i - 1] == '\n')
> + cbuf[i - 1] = 0;
> else
> - cbuf[i] = 0;
> + cbuf[i] = 0;
You are not aligning the '=' here, so don't add extra spaces.
> s->buggy_avid = 1;
> - // if (s->first_picture)
> - // printf("mjpeg: workarounding buggy AVID\n");
> + //if (s->first_picture)
> + //printf("mjpeg: workarounding buggy AVID\n");
space after //
> @@ -1427,148 +1428,145 @@ int ff_mjpeg_decode_frame(AVCodecContext *avctx,
> /* find start next marker */
> start_code = ff_mjpeg_find_marker(s, &buf_ptr, buf_end,
> &unescaped_buf_ptr,
> &unescaped_buf_size);
> - {
> - /* EOF */
> - if (start_code < 0) {
> - goto the_end;
> - } else {
> + /* EOF */
> + if (start_code < 0)
> + goto the_end;
No, no, no, you cannot just remove the block braces.
Put them back and keep the indentation.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel