Simple OpenMP parallelization

This commit is contained in:
Laurent Fasnacht 2014-04-25 09:11:10 +02:00
parent 4b861deacd
commit 7719837f17
2 changed files with 7 additions and 6 deletions

View file

@ -5,7 +5,7 @@ ifeq (, $(ARCH))
endif
SYSTEM = $(shell uname -s)
ASMFLAGS =
DFLAGS = -O2 -g -Werror
DFLAGS = -O2 -g -Werror -DUSE_TILES=1
# ARCH related flags
ifeq ($(ARCH), x86_64)
@ -44,10 +44,10 @@ else
endif
endif
CC = gcc
CC = gcc -fopenmp
CCFLAGS = $(DFLAGS) -I. -I/usr/local/include -L/usr/local/lib -Wall
LDFLAGS += -lm
LD = gcc
LD = gcc -fopenmp
YASM = yasm
ASMOBJS = cpu.o
OBJS = interface_main.o encmain.o bitstream.o cabac.o config.o context.o encoder.o filter.o inter.o intra.o nal.o picture.o rdo.o sao.o scalinglist.o search.o tables.o transform.o extras/getopt.o

View file

@ -715,8 +715,9 @@ void encode_one_frame(encoder_state * const encoder_state)
if (USE_TILES && encoder->tiles_enable) {
#if USE_TILES
int i,x,y;
int x,y;
//This can be parallelized
#pragma omp parallel for private(x,y) collapse(2)
for (y=0; y < encoder->tiles_num_tile_rows; ++y) {
for (x=0; x < encoder->tiles_num_tile_columns; ++x) {
const int tile_width_in_lcu = encoder->tiles_col_bd[x+1]-encoder->tiles_col_bd[x];
@ -727,7 +728,7 @@ void encode_one_frame(encoder_state * const encoder_state)
const int tile_height = MIN(tile_height_in_lcu * LCU_WIDTH, encoder->in.height - tile_offset_y);
const int tile_offset_full = tile_offset_x+tile_offset_y*encoder_state->cur_pic->width;
const int tile_offset_half = tile_offset_x/2+tile_offset_y/2*encoder_state->cur_pic->width/2;
i = y * encoder->tiles_num_tile_columns + x;
const int i = y * encoder->tiles_num_tile_columns + x;
//TODO: ref frames
@ -751,7 +752,7 @@ void encode_one_frame(encoder_state * const encoder_state)
//This has to be serial
for (y=0; y < encoder->tiles_num_tile_rows; ++y) {
for (x=0; x < encoder->tiles_num_tile_columns; ++x) {
i = y * encoder->tiles_num_tile_columns + x;
const int i = y * encoder->tiles_num_tile_columns + x;
if (x == (encoder->tiles_num_tile_columns-1) && y == (encoder->tiles_num_tile_rows-1)) {
//Last tile