Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Orientation SEI #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 86 additions & 3 deletions h264_sei.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void read_sei_end_bits(h264_stream_t* h, bs_t* b )


void read_sei_scalability_info( h264_stream_t* h, bs_t* b );
void read_sei_display_orientation( h264_stream_t* h, bs_t* b );
void read_sei_payload( h264_stream_t* h, bs_t* b );


Expand Down Expand Up @@ -248,6 +249,25 @@ void read_sei_scalability_info( h264_stream_t* h, bs_t* b )

}


// Appendix D.1.27 Display Orientation SEI message syntax
void read_sei_display_orientation( h264_stream_t* h, bs_t* b )
{
sei_display_orientation_t* sei_do = h->sei->sei_do;

sei_do->cancel = bs_read_u1(b);

if( !sei_do->cancel )
{
sei_do->hor_flip = bs_read_u1(b);
sei_do->ver_flip = bs_read_u1(b);
sei_do->anticlockwise_rotation = bs_read_u(b, 16);
sei_do->display_orientation_repetition_period = bs_read_ue(b);
sei_do->display_orientation_extension_flag = bs_read_u1(b);
}

}

// D.1 SEI payload syntax
void read_sei_payload( h264_stream_t* h, bs_t* b )
{
Expand All @@ -263,14 +283,23 @@ void read_sei_payload( h264_stream_t* h, bs_t* b )
}
read_sei_scalability_info( h, b );
break;
case SEI_TYPE_DISPLAY_ORIENTATION:
if( 1 )
{
s->sei_do = (sei_display_orientation_t*)calloc( 1, sizeof(sei_display_orientation_t) );
}
read_sei_display_orientation( h, b );
break;
default:
if( 1 )
{
s->data = (uint8_t*)calloc(1, s->payloadSize);
}

for ( i = 0; i < s->payloadSize; i++ )
{
s->data[i] = bs_read_u8(b);
}
}

//if( 1 )
Expand All @@ -279,6 +308,7 @@ void read_sei_payload( h264_stream_t* h, bs_t* b )


void write_sei_scalability_info( h264_stream_t* h, bs_t* b );
void write_sei_display_orientation( h264_stream_t* h, bs_t* b );
void write_sei_payload( h264_stream_t* h, bs_t* b );


Expand Down Expand Up @@ -455,6 +485,25 @@ void write_sei_scalability_info( h264_stream_t* h, bs_t* b )

}


// Appendix D.1.27 Display Orientation SEI message syntax
void write_sei_display_orientation( h264_stream_t* h, bs_t* b )
{
sei_display_orientation_t* sei_do = h->sei->sei_do;

bs_write_u1(b, sei_do->cancel);

if( !sei_do->cancel )
{
bs_write_u1(b, sei_do->hor_flip);
bs_write_u1(b, sei_do->ver_flip);
bs_write_u(b, 16, sei_do->anticlockwise_rotation);
bs_write_ue(b, sei_do->display_orientation_repetition_period);
bs_write_u1(b, sei_do->display_orientation_extension_flag);
}

}

// D.1 SEI payload syntax
void write_sei_payload( h264_stream_t* h, bs_t* b )
{
Expand All @@ -470,14 +519,23 @@ void write_sei_payload( h264_stream_t* h, bs_t* b )
}
write_sei_scalability_info( h, b );
break;
case SEI_TYPE_DISPLAY_ORIENTATION:
if( 0 )
{
s->sei_do = (sei_display_orientation_t*)calloc( 1, sizeof(sei_display_orientation_t) );
}
write_sei_display_orientation( h, b );
break;
default:
if( 0 )
{
s->data = (uint8_t*)calloc(1, s->payloadSize);
}

for ( i = 0; i < s->payloadSize; i++ )
{
bs_write_u8(b, s->data[i]);
}
}

//if( 0 )
Expand All @@ -486,6 +544,7 @@ void write_sei_payload( h264_stream_t* h, bs_t* b )


void read_debug_sei_scalability_info( h264_stream_t* h, bs_t* b );
void read_debug_sei_display_orientation( h264_stream_t* h, bs_t* b );
void read_debug_sei_payload( h264_stream_t* h, bs_t* b );


Expand Down Expand Up @@ -662,6 +721,25 @@ void read_debug_sei_scalability_info( h264_stream_t* h, bs_t* b )

}


// Appendix D.1.27 Display Orientation SEI message syntax
void read_debug_sei_display_orientation( h264_stream_t* h, bs_t* b )
{
sei_display_orientation_t* sei_do = h->sei->sei_do;

printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left); sei_do->cancel = bs_read_u1(b); printf("sei_do->cancel: %d \n", sei_do->cancel);

if( !sei_do->cancel )
{
printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left); sei_do->hor_flip = bs_read_u1(b); printf("sei_do->hor_flip: %d \n", sei_do->hor_flip);
printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left); sei_do->ver_flip = bs_read_u1(b); printf("sei_do->ver_flip: %d \n", sei_do->ver_flip);
printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left); sei_do->anticlockwise_rotation = bs_read_u(b, 16); printf("sei_do->anticlockwise_rotation: %d \n", sei_do->anticlockwise_rotation);
printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left); sei_do->display_orientation_repetition_period = bs_read_ue(b); printf("sei_do->display_orientation_repetition_period: %d \n", sei_do->display_orientation_repetition_period);
printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left); sei_do->display_orientation_extension_flag = bs_read_u1(b); printf("sei_do->display_orientation_extension_flag: %d \n", sei_do->display_orientation_extension_flag);
}

}

// D.1 SEI payload syntax
void read_debug_sei_payload( h264_stream_t* h, bs_t* b )
{
Expand All @@ -677,6 +755,13 @@ void read_debug_sei_payload( h264_stream_t* h, bs_t* b )
}
read_debug_sei_scalability_info( h, b );
break;
case SEI_TYPE_DISPLAY_ORIENTATION:
if( 1 )
{
s->sei_do = (sei_display_orientation_t*)calloc( 1, sizeof(sei_display_orientation_t) );
}
read_debug_sei_display_orientation( h, b );
break;
default:
if( 1 )
{
Expand All @@ -685,9 +770,7 @@ void read_debug_sei_payload( h264_stream_t* h, bs_t* b )

for ( i = 0; i < s->payloadSize; i++ )
{
printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left);
s->data[i] = bs_read_u8(b);
printf("s->data[i]: %d \n", s->data[i]);
printf("%ld.%d: ", (long int)(b->p - b->start), b->bits_left); s->data[i] = bs_read_u8(b); printf("s->data[i]: %d \n", s->data[i]);
}
}

Expand Down
12 changes: 12 additions & 0 deletions h264_sei.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ typedef struct
} pr[MAX_J];
} sei_scalability_info_t;

typedef struct
{
bool cancel;
bool hor_flip;
bool ver_flip;
unsigned short anticlockwise_rotation;
int display_orientation_repetition_period;
bool display_orientation_extension_flag;
} sei_display_orientation_t;

typedef struct
{
int payloadType;
Expand All @@ -141,6 +151,7 @@ typedef struct
union
{
sei_scalability_info_t* sei_svc;
sei_display_orientation_t* sei_do;
uint8_t* data;
};
} sei_t;
Expand Down Expand Up @@ -172,6 +183,7 @@ void sei_free(sei_t* s);
#define SEI_TYPE_DEBLOCKING_FILTER_DISPLAY_PREFERENCE 20
#define SEI_TYPE_STEREO_VIDEO_INFO 21
#define SEI_TYPE_SCALABILITY_INFO 24
#define SEI_TYPE_DISPLAY_ORIENTATION 47

#ifdef __cplusplus
}
Expand Down
30 changes: 29 additions & 1 deletion h264_sei.in.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,25 @@ void structure(sei_scalability_info)( h264_stream_t* h, bs_t* b )

}


// Appendix D.1.27 Display Orientation SEI message syntax
void structure(sei_display_orientation)( h264_stream_t* h, bs_t* b )
{
sei_display_orientation_t* sei_do = h->sei->sei_do;

value( sei_do->cancel, u1 );

if( !sei_do->cancel )
{
value( sei_do->hor_flip, u1 );
value( sei_do->ver_flip, u1 );
value( sei_do->anticlockwise_rotation, u(16) );
value( sei_do->display_orientation_repetition_period, ue );
value( sei_do->display_orientation_extension_flag, u1 );
}

}

// D.1 SEI payload syntax
void structure(sei_payload)( h264_stream_t* h, bs_t* b )
{
Expand All @@ -257,18 +276,27 @@ void structure(sei_payload)( h264_stream_t* h, bs_t* b )
case SEI_TYPE_SCALABILITY_INFO:
if( is_reading )
{
s->sei_svc = (uint8_t*)calloc( 1, sizeof(sei_scalability_info_t) );
s->sei_svc = (sei_scalability_info_t*)calloc( 1, sizeof(sei_scalability_info_t) );
}
structure(sei_scalability_info)( h, b );
break;
case SEI_TYPE_DISPLAY_ORIENTATION:
if( is_reading )
{
s->sei_do = (sei_display_orientation_t*)calloc( 1, sizeof(sei_display_orientation_t) );
}
structure(sei_display_orientation)( h, b );
break;
default:
if( is_reading )
{
s->data = (uint8_t*)calloc(1, s->payloadSize);
}

for ( i = 0; i < s->payloadSize; i++ )
{
value( s->data[i], u8 );
}
}

//if( is_reading )
Expand Down
2 changes: 1 addition & 1 deletion process.pl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ sub proc_value_read_debug
$code = "if (cabac) { $s = bs_read_ae(b); }" . "\n${indent}" . "else { $code }";
}

$code = "printf(\"\%d.\%d: \", b->p - b->start, b->bits_left); ".
$code = "printf(\"\%ld.\%d: \", (long int)(b->p - b->start), b->bits_left); ".
$code .
" printf(\"$s: \%d \\n\", $s); ";

Expand Down