|
|
|
@ -33,8 +33,8 @@
|
|
|
|
|
#include "attributes.h"
|
|
|
|
|
#include "mpeg2_internal.h"
|
|
|
|
|
|
|
|
|
|
#define SETQ_EXT 2
|
|
|
|
|
#define SETQ_DISPLAY_EXT 4
|
|
|
|
|
#define SEQ_EXT 2
|
|
|
|
|
#define SEQ_DISPLAY_EXT 4
|
|
|
|
|
#define QUANT_MATRIX_EXT 8
|
|
|
|
|
#define COPYRIGHT_EXT 0x10
|
|
|
|
|
#define PIC_DISPLAY_EXT 0x80
|
|
|
|
@ -156,8 +156,8 @@ int mpeg2_header_sequence (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
sequence->chroma_width = sequence->width >> 1;
|
|
|
|
|
sequence->chroma_height = sequence->height >> 1;
|
|
|
|
|
|
|
|
|
|
sequence->flags = (SETQ_FLAG_PROGRESSIVE_SEQUENCE |
|
|
|
|
|
SETQ_VIDEO_FORMAT_UNSPECIFIED);
|
|
|
|
|
sequence->flags = (SEQ_FLAG_PROGRESSIVE_SEQUENCE |
|
|
|
|
|
SEQ_VIDEO_FORMAT_UNSPECIFIED);
|
|
|
|
|
|
|
|
|
|
sequence->pixel_width = buffer[3] >> 4; /* aspect ratio */
|
|
|
|
|
sequence->frame_period = frame_period[buffer[3] & 15];
|
|
|
|
@ -167,7 +167,7 @@ int mpeg2_header_sequence (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
sequence->vbv_buffer_size = ((buffer[6]<<16)|(buffer[7]<<8))&0x1ff800;
|
|
|
|
|
|
|
|
|
|
if (buffer[7] & 4)
|
|
|
|
|
sequence->flags |= SETQ_FLAG_CONSTRAINED_PARAMETERS;
|
|
|
|
|
sequence->flags |= SEQ_FLAG_CONSTRAINED_PARAMETERS;
|
|
|
|
|
|
|
|
|
|
mpeg2dec->copy_matrix = 3;
|
|
|
|
|
if (buffer[7] & 2) {
|
|
|
|
@ -192,7 +192,7 @@ int mpeg2_header_sequence (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
sequence->transfer_characteristics = 0;
|
|
|
|
|
sequence->matrix_coefficients = 0;
|
|
|
|
|
|
|
|
|
|
mpeg2dec->ext_state = SETQ_EXT;
|
|
|
|
|
mpeg2dec->ext_state = SEQ_EXT;
|
|
|
|
|
mpeg2dec->state = STATE_SEQUENCE;
|
|
|
|
|
mpeg2dec->display_offset_x = mpeg2dec->display_offset_y = 0;
|
|
|
|
|
|
|
|
|
@ -216,13 +216,13 @@ static int sequence_ext (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
(buffer[2] << 7) & 0x3000;
|
|
|
|
|
sequence->width = (sequence->picture_width + 15) & ~15;
|
|
|
|
|
sequence->height = (sequence->picture_height + 15) & ~15;
|
|
|
|
|
flags = sequence->flags | SETQ_FLAG_MPEG2;
|
|
|
|
|
flags = sequence->flags | SEQ_FLAG_MPEG2;
|
|
|
|
|
if (!(buffer[1] & 8)) {
|
|
|
|
|
flags &= ~SETQ_FLAG_PROGRESSIVE_SEQUENCE;
|
|
|
|
|
flags &= ~SEQ_FLAG_PROGRESSIVE_SEQUENCE;
|
|
|
|
|
sequence->height = (sequence->height + 31) & ~31;
|
|
|
|
|
}
|
|
|
|
|
if (buffer[5] & 0x80)
|
|
|
|
|
flags |= SETQ_FLAG_LOW_DELAY;
|
|
|
|
|
flags |= SEQ_FLAG_LOW_DELAY;
|
|
|
|
|
sequence->flags = flags;
|
|
|
|
|
sequence->chroma_width = sequence->width;
|
|
|
|
|
sequence->chroma_height = sequence->height;
|
|
|
|
@ -242,7 +242,7 @@ static int sequence_ext (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
sequence->frame_period =
|
|
|
|
|
sequence->frame_period * ((buffer[5]&31)+1) / (((buffer[5]>>2)&3)+1);
|
|
|
|
|
|
|
|
|
|
mpeg2dec->ext_state = SETQ_DISPLAY_EXT;
|
|
|
|
|
mpeg2dec->ext_state = SEQ_DISPLAY_EXT;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -253,10 +253,10 @@ static int sequence_display_ext (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
mpeg2_sequence_t * sequence = &(mpeg2dec->new_sequence);
|
|
|
|
|
uint32_t flags;
|
|
|
|
|
|
|
|
|
|
flags = ((sequence->flags & ~SETQ_MASK_VIDEO_FORMAT) |
|
|
|
|
|
((buffer[0]<<4) & SETQ_MASK_VIDEO_FORMAT));
|
|
|
|
|
flags = ((sequence->flags & ~SEQ_MASK_VIDEO_FORMAT) |
|
|
|
|
|
((buffer[0]<<4) & SEQ_MASK_VIDEO_FORMAT));
|
|
|
|
|
if (buffer[0] & 1) {
|
|
|
|
|
flags |= SETQ_FLAG_COLOUR_DESCRIPTION;
|
|
|
|
|
flags |= SEQ_FLAG_COLOUR_DESCRIPTION;
|
|
|
|
|
sequence->colour_primaries = buffer[1];
|
|
|
|
|
sequence->transfer_characteristics = buffer[2];
|
|
|
|
|
sequence->matrix_coefficients = buffer[3];
|
|
|
|
@ -280,7 +280,7 @@ static inline void finalize_sequence (mpeg2_sequence_t * sequence)
|
|
|
|
|
|
|
|
|
|
sequence->byte_rate *= 50;
|
|
|
|
|
|
|
|
|
|
if (sequence->flags & SETQ_FLAG_MPEG2) {
|
|
|
|
|
if (sequence->flags & SEQ_FLAG_MPEG2) {
|
|
|
|
|
switch (sequence->pixel_width) {
|
|
|
|
|
case 1: /* square pixels */
|
|
|
|
|
sequence->pixel_width = sequence->pixel_height = 1; return;
|
|
|
|
@ -376,7 +376,7 @@ void mpeg2_header_sequence_finalize (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
finalize_sequence (sequence);
|
|
|
|
|
finalize_matrix (mpeg2dec);
|
|
|
|
|
|
|
|
|
|
decoder->mpeg1 = !(sequence->flags & SETQ_FLAG_MPEG2);
|
|
|
|
|
decoder->mpeg1 = !(sequence->flags & SEQ_FLAG_MPEG2);
|
|
|
|
|
decoder->width = sequence->width;
|
|
|
|
|
decoder->height = sequence->height;
|
|
|
|
|
decoder->vertical_position_extension = (sequence->picture_height > 2800);
|
|
|
|
@ -451,7 +451,7 @@ void mpeg2_set_fbuf (mpeg2dec_t * mpeg2dec, int b_type)
|
|
|
|
|
mpeg2dec->fbuf[2] != &mpeg2dec->fbuf_alloc[i].fbuf) {
|
|
|
|
|
mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[i].fbuf;
|
|
|
|
|
mpeg2dec->info.current_fbuf = mpeg2dec->fbuf[0];
|
|
|
|
|
if (b_type || (mpeg2dec->sequence.flags & SETQ_FLAG_LOW_DELAY)) {
|
|
|
|
|
if (b_type || (mpeg2dec->sequence.flags & SEQ_FLAG_LOW_DELAY)) {
|
|
|
|
|
if (b_type || mpeg2dec->convert)
|
|
|
|
|
mpeg2dec->info.discard_fbuf = mpeg2dec->fbuf[0];
|
|
|
|
|
mpeg2dec->info.display_fbuf = mpeg2dec->fbuf[0];
|
|
|
|
@ -549,7 +549,7 @@ static int picture_coding_ext (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
picture->nb_fields = 1;
|
|
|
|
|
break;
|
|
|
|
|
case FRAME_PICTURE:
|
|
|
|
|
if (!(mpeg2dec->sequence.flags & SETQ_FLAG_PROGRESSIVE_SEQUENCE)) {
|
|
|
|
|
if (!(mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)) {
|
|
|
|
|
picture->nb_fields = (buffer[3] & 2) ? 3 : 2;
|
|
|
|
|
flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0;
|
|
|
|
|
} else
|
|
|
|
@ -582,7 +582,7 @@ static int picture_display_ext (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
int i, nb_pos;
|
|
|
|
|
|
|
|
|
|
nb_pos = picture->nb_fields;
|
|
|
|
|
if (mpeg2dec->sequence.flags & SETQ_FLAG_PROGRESSIVE_SEQUENCE)
|
|
|
|
|
if (mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)
|
|
|
|
|
nb_pos >>= 1;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < nb_pos; i++) {
|
|
|
|
@ -608,7 +608,7 @@ void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec, uint32_t accels)
|
|
|
|
|
{
|
|
|
|
|
mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
|
|
|
|
|
int old_type_b = (decoder->coding_type == B_TYPE);
|
|
|
|
|
int low_delay = mpeg2dec->sequence.flags & SETQ_FLAG_LOW_DELAY;
|
|
|
|
|
int low_delay = mpeg2dec->sequence.flags & SEQ_FLAG_LOW_DELAY;
|
|
|
|
|
|
|
|
|
|
finalize_matrix (mpeg2dec);
|
|
|
|
|
decoder->coding_type = mpeg2dec->new_picture.flags & PIC_MASK_CODING_TYPE;
|
|
|
|
@ -878,7 +878,7 @@ mpeg2_state_t mpeg2_header_end (mpeg2dec_t * mpeg2dec)
|
|
|
|
|
picture = mpeg2dec->pictures + 2;
|
|
|
|
|
|
|
|
|
|
mpeg2_reset_info (&(mpeg2dec->info));
|
|
|
|
|
if (!(mpeg2dec->sequence.flags & SETQ_FLAG_LOW_DELAY)) {
|
|
|
|
|
if (!(mpeg2dec->sequence.flags & SEQ_FLAG_LOW_DELAY)) {
|
|
|
|
|
mpeg2dec->info.display_picture = picture;
|
|
|
|
|
if (picture->nb_fields == 1)
|
|
|
|
|
mpeg2dec->info.display_picture_2nd = picture + 1;
|
|
|
|
|