Replace all (x == NULL) or (x != NULL) in assert and if conditions by !x and x.
[ffmpeg.git] / libavcodec / mpegvideo_xvmc.c
index 3ad2636..dd3ff13 100644 (file)
@@ -40,12 +40,12 @@ void XVMC_init_block(MpegEncContext *s)
 {
     struct xvmc_render_state * render;
     render = (struct xvmc_render_state*)s->current_picture.data[2];
-    assert(render != NULL);
-    if ((render == NULL) || (render->magic != MP_XVMC_RENDER_MAGIC)) {
+    assert(render);
+    if (!render || (render->magic != MP_XVMC_RENDER_MAGIC)) {
         assert(0);
         return;//make sure that this is a render packet
     }
-    s->block =(DCTELEM *)(render->data_blocks+(render->next_free_data_block_num)*64);
+    s->block = (DCTELEM *)(render->data_blocks+(render->next_free_data_block_num)*64);
 }
 
 void XVMC_pack_pblocks(MpegEncContext *s, int cbp)
@@ -71,30 +71,29 @@ int XVMC_field_start(MpegEncContext*s, AVCodecContext *avctx)
 {
     struct xvmc_render_state * render, * last, * next;
 
-    assert(avctx != NULL);
+    assert(avctx);
 
     render = (struct xvmc_render_state*)s->current_picture.data[2];
-    assert(render != NULL);
-    if ((render == NULL) || (render->magic != MP_XVMC_RENDER_MAGIC))
+    assert(render);
+    if (!render || (render->magic != MP_XVMC_RENDER_MAGIC))
         return -1;//make sure that this is render packet
 
     render->picture_structure = s->picture_structure;
-    render->flags = (s->first_field)? 0: XVMC_SECOND_FIELD;
+    render->flags             = (s->first_field) ? 0 : XVMC_SECOND_FIELD;
 
 //make sure that all data is drawn by XVMC_end_frame
-    assert(render->filled_mv_blocks_num==0);
+    assert(render->filled_mv_blocks_num == 0);
 
     render->p_future_surface = NULL;
-    render->p_past_surface = NULL;
+    render->p_past_surface   = NULL;
 
     switch(s->pict_type){
         case  FF_I_TYPE:
             return 0;// no prediction from other frames
         case  FF_B_TYPE:
             next = (struct xvmc_render_state*)s->next_picture.data[2];
-            assert(next!=NULL);
-            assert(next->state & MP_XVMC_STATE_PREDICTION);
-            if (next == NULL)
+            assert(next);
+            if (!next)
                 return -1;
             if (next->magic != MP_XVMC_RENDER_MAGIC)
                 return -1;
@@ -102,11 +101,10 @@ int XVMC_field_start(MpegEncContext*s, AVCodecContext *avctx)
             //no return here, going to set forward prediction
         case  FF_P_TYPE:
             last = (struct xvmc_render_state*)s->last_picture.data[2];
-            if (last == NULL)// && !s->first_field)
+            if (!last)// && !s->first_field)
                 last = render;//predict second field from the first
             if (last->magic != MP_XVMC_RENDER_MAGIC)
                 return -1;
-            assert(last->state & MP_XVMC_STATE_PREDICTION);
             render->p_past_surface = last->p_surface;
             return 0;
     }
@@ -118,7 +116,7 @@ void XVMC_field_end(MpegEncContext *s)
 {
     struct xvmc_render_state * render;
     render = (struct xvmc_render_state*)s->current_picture.data[2];
-    assert(render != NULL);
+    assert(render);
 
     if (render->filled_mv_blocks_num > 0)
         ff_draw_horiz_band(s,0,0);
@@ -156,7 +154,7 @@ void XVMC_decode_mb(MpegEncContext *s)
 
 //START OF XVMC specific code
     render = (struct xvmc_render_state*)s->current_picture.data[2];
-    assert(render!=NULL);
+    assert(render);
     assert(render->magic==MP_XVMC_RENDER_MAGIC);
     assert(render->mv_blocks);
 
@@ -164,8 +162,8 @@ void XVMC_decode_mb(MpegEncContext *s)
     mv_block = &render->mv_blocks[render->start_mv_blocks_num +
                                   render->filled_mv_blocks_num ];
 
-    mv_block->x = s->mb_x;
-    mv_block->y = s->mb_y;
+    mv_block->x        = s->mb_x;
+    mv_block->y        = s->mb_y;
     mv_block->dct_type = s->interlaced_dct;//XVMC_DCT_TYPE_FRAME/FIELD;
     if (s->mb_intra){
         mv_block->macroblock_type = XVMC_MB_TYPE_INTRA;//no MC, all done
@@ -173,7 +171,7 @@ void XVMC_decode_mb(MpegEncContext *s)
         mv_block->macroblock_type = XVMC_MB_TYPE_PATTERN;
 
         if (s->mv_dir & MV_DIR_FORWARD) {
-            mv_block->macroblock_type|= XVMC_MB_TYPE_MOTION_FORWARD;
+            mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_FORWARD;
             //pmv[n][dir][xy]=mv[dir][n][xy]
             mv_block->PMV[0][0][0] = s->mv[0][0][0];
             mv_block->PMV[0][0][1] = s->mv[0][0][1];
@@ -181,7 +179,7 @@ void XVMC_decode_mb(MpegEncContext *s)
             mv_block->PMV[1][0][1] = s->mv[0][1][1];
         }
         if (s->mv_dir & MV_DIR_BACKWARD) {
-            mv_block->macroblock_type|=XVMC_MB_TYPE_MOTION_BACKWARD;
+            mv_block->macroblock_type |= XVMC_MB_TYPE_MOTION_BACKWARD;
             mv_block->PMV[0][1][0] = s->mv[1][0][0];
             mv_block->PMV[0][1][1] = s->mv[1][0][1];
             mv_block->PMV[1][1][0] = s->mv[1][1][0];
@@ -254,7 +252,7 @@ void XVMC_decode_mb(MpegEncContext *s)
 //  calculate cbp
     cbp = 0;
     for (i = 0; i < blocks_per_mb; i++) {
-        cbp+= cbp;
+        cbp += cbp;
         if (s->block_last_index[i] >= 0)
             cbp++;
     }
@@ -294,7 +292,7 @@ void XVMC_decode_mb(MpegEncContext *s)
     }
     render->filled_mv_blocks_num++;
 
-    assert(render->filled_mv_blocks_num <= render->total_number_of_mv_blocks);
+    assert(render->filled_mv_blocks_num     <= render->total_number_of_mv_blocks);
     assert(render->next_free_data_block_num <= render->total_number_of_data_blocks);