-
Notifications
You must be signed in to change notification settings - Fork 1
/
slicerow.cpp
63 lines (49 loc) · 1.59 KB
/
slicerow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <pthread.h>
#include "slicerow.hpp"
#include "exceptions.hpp"
#include "mutexobj.hpp"
SliceRow::SliceRow( uint s_row, uint s_mb_height )
: row( s_row ),
mb_height( s_mb_height )
{
unixassert( pthread_mutex_init( &mutex, NULL ) );
unixassert( pthread_cond_init( &activity, NULL ) );
state = SR_BLANK;
}
SliceRow::~SliceRow()
{
unixassert( pthread_cond_destroy( &activity ) );
unixassert( pthread_mutex_destroy( &mutex ) );
}
void SliceRow::init( int f_code_fv, int f_code_bv,
Picture *forward, Picture *backward )
{
forward_highest_dependent_row = forward_lowest_dependent_row = -1;
backward_highest_dependent_row = backward_lowest_dependent_row = -1;
if ( forward && (f_code_fv != 15) ) {
int diff;
if ( f_code_fv == 1 ) {
diff = 1;
} else {
diff = 1 << (f_code_fv - 2);
}
forward_highest_dependent_row = row - diff;
if ( forward_highest_dependent_row < 0 ) forward_highest_dependent_row = 0;
forward_lowest_dependent_row = row + diff;
if ( forward_lowest_dependent_row >= (int)mb_height ) forward_lowest_dependent_row = mb_height - 1;
}
if ( backward && (f_code_bv != 15) ) {
int diff;
if ( f_code_bv == 1 ) {
diff = 1;
} else {
diff = 1 << (f_code_bv - 2);
}
backward_highest_dependent_row = row - diff;
if ( backward_highest_dependent_row < 0 ) backward_highest_dependent_row = 0;
backward_lowest_dependent_row = row + diff;
if ( backward_lowest_dependent_row >= (int)mb_height ) backward_lowest_dependent_row = mb_height - 1;
}
MutexLock x( &mutex );
state = SR_READY;
}