Fix palette mode in multi-thread encoding setting
Fix a couple of memory related errors. Also fix thread test failures. Change-Id: I0103995f832cecf1dd2380000321ac7204f0cfc0
This commit is contained in:
		@@ -1933,7 +1933,7 @@ static size_t read_uncompressed_header(VP10Decoder *pbi,
 | 
				
			|||||||
      memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
 | 
					      memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
 | 
				
			||||||
      pbi->need_resync = 0;
 | 
					      pbi->need_resync = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (cm->current_video_frame == 0)
 | 
					    if (frame_is_intra_only(cm))
 | 
				
			||||||
      cm->allow_screen_content_tools = vpx_rb_read_bit(rb);
 | 
					      cm->allow_screen_content_tools = vpx_rb_read_bit(rb);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    cm->intra_only = cm->show_frame ? 0 : vpx_rb_read_bit(rb);
 | 
					    cm->intra_only = cm->show_frame ? 0 : vpx_rb_read_bit(rb);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1217,7 +1217,7 @@ static void write_uncompressed_header(VP10_COMP *cpi,
 | 
				
			|||||||
    write_sync_code(wb);
 | 
					    write_sync_code(wb);
 | 
				
			||||||
    write_bitdepth_colorspace_sampling(cm, wb);
 | 
					    write_bitdepth_colorspace_sampling(cm, wb);
 | 
				
			||||||
    write_frame_size(cm, wb);
 | 
					    write_frame_size(cm, wb);
 | 
				
			||||||
    if (cm->current_video_frame == 0)
 | 
					    if (frame_is_intra_only(cm))
 | 
				
			||||||
      vpx_wb_write_bit(wb, cm->allow_screen_content_tools);
 | 
					      vpx_wb_write_bit(wb, cm->allow_screen_content_tools);
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
    if (!cm->show_frame)
 | 
					    if (!cm->show_frame)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1945,11 +1945,11 @@ void vp10_remove_compressor(VP10_COMP *cpi) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Deallocate allocated thread data.
 | 
					    // Deallocate allocated thread data.
 | 
				
			||||||
    if (t < cpi->num_workers - 1) {
 | 
					    if (t < cpi->num_workers - 1) {
 | 
				
			||||||
 | 
					      if (cpi->common.allow_screen_content_tools)
 | 
				
			||||||
 | 
					        vpx_free(thread_data->td->mb.palette_buffer);
 | 
				
			||||||
      vpx_free(thread_data->td->counts);
 | 
					      vpx_free(thread_data->td->counts);
 | 
				
			||||||
      vp10_free_pc_tree(thread_data->td);
 | 
					      vp10_free_pc_tree(thread_data->td);
 | 
				
			||||||
      vpx_free(thread_data->td);
 | 
					      vpx_free(thread_data->td);
 | 
				
			||||||
      if (cpi->common.allow_screen_content_tools)
 | 
					 | 
				
			||||||
        vpx_free(thread_data->td->mb.palette_buffer);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  vpx_free(cpi->tile_thr_data);
 | 
					  vpx_free(cpi->tile_thr_data);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,13 +96,6 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) {
 | 
				
			|||||||
        CHECK_MEM_ERROR(cm, thread_data->td->counts,
 | 
					        CHECK_MEM_ERROR(cm, thread_data->td->counts,
 | 
				
			||||||
                        vpx_calloc(1, sizeof(*thread_data->td->counts)));
 | 
					                        vpx_calloc(1, sizeof(*thread_data->td->counts)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Allocate buffers used by palette coding mode.
 | 
					 | 
				
			||||||
        if (cpi->common.allow_screen_content_tools) {
 | 
					 | 
				
			||||||
          MACROBLOCK *x = &thread_data->td->mb;
 | 
					 | 
				
			||||||
          CHECK_MEM_ERROR(cm, x->palette_buffer,
 | 
					 | 
				
			||||||
                          vpx_memalign(16, sizeof(*x->palette_buffer)));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Create threads
 | 
					        // Create threads
 | 
				
			||||||
        if (!winterface->reset(worker))
 | 
					        if (!winterface->reset(worker))
 | 
				
			||||||
          vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
 | 
					          vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
 | 
				
			||||||
@@ -135,6 +128,13 @@ void vp10_encode_tiles_mt(VP10_COMP *cpi) {
 | 
				
			|||||||
      memcpy(thread_data->td->counts, &cpi->common.counts,
 | 
					      memcpy(thread_data->td->counts, &cpi->common.counts,
 | 
				
			||||||
             sizeof(cpi->common.counts));
 | 
					             sizeof(cpi->common.counts));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Allocate buffers used by palette coding mode.
 | 
				
			||||||
 | 
					    if (cpi->common.allow_screen_content_tools && i < num_workers - 1) {
 | 
				
			||||||
 | 
					        MACROBLOCK *x = &thread_data->td->mb;
 | 
				
			||||||
 | 
					        CHECK_MEM_ERROR(cm, x->palette_buffer,
 | 
				
			||||||
 | 
					                        vpx_memalign(16, sizeof(*x->palette_buffer)));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Encode a frame
 | 
					  // Encode a frame
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1204,8 +1204,8 @@ static int64_t rd_pick_intra_sby_mode(VP10_COMP *cpi, MACROBLOCK *x,
 | 
				
			|||||||
  TX_SIZE best_tx = TX_4X4;
 | 
					  TX_SIZE best_tx = TX_4X4;
 | 
				
			||||||
  int *bmode_costs;
 | 
					  int *bmode_costs;
 | 
				
			||||||
  PALETTE_MODE_INFO palette_mode_info;
 | 
					  PALETTE_MODE_INFO palette_mode_info;
 | 
				
			||||||
  uint8_t *best_palette_color_map =  cpi->common.allow_screen_content_tools ?
 | 
					  uint8_t *best_palette_color_map = cpi->common.allow_screen_content_tools ?
 | 
				
			||||||
       x->palette_buffer->best_palette_color_map : NULL;
 | 
					      x->palette_buffer->best_palette_color_map : NULL;
 | 
				
			||||||
  int rows = 4 * num_4x4_blocks_high_lookup[bsize];
 | 
					  int rows = 4 * num_4x4_blocks_high_lookup[bsize];
 | 
				
			||||||
  int cols = 4 * num_4x4_blocks_wide_lookup[bsize];
 | 
					  int cols = 4 * num_4x4_blocks_wide_lookup[bsize];
 | 
				
			||||||
  int palette_ctx = 0;
 | 
					  int palette_ctx = 0;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user