Doxygen Source Code Documentation
header.c File Reference
#include "config.h"
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include "mpeg2.h"
#include "mpeg2_internal.h"
#include "convert.h"
#include "attributes.h"
Go to the source code of this file.
Define Documentation
|
Definition at line 38 of file header.c. Referenced by picture_coding_ext(). |
|
Definition at line 40 of file header.c. Referenced by mpeg2_header_picture(). |
|
Definition at line 39 of file header.c. Referenced by picture_coding_ext(). |
|
Definition at line 37 of file header.c. Referenced by picture_coding_ext(). |
|
Definition at line 36 of file header.c. Referenced by sequence_ext(). |
|
Definition at line 35 of file header.c. Referenced by mpeg2_header_sequence(). |
Function Documentation
|
Definition at line 43 of file header.c. References uint8_t.
00043 { 00044 8, 00045 16, 16, 00046 19, 16, 19, 00047 22, 22, 22, 22, 00048 22, 22, 26, 24, 26, 00049 27, 27, 27, 26, 26, 26, 00050 26, 27, 27, 27, 29, 29, 29, 00051 34, 34, 34, 29, 29, 29, 27, 27, 00052 29, 29, 32, 32, 34, 34, 37, 00053 38, 37, 35, 35, 34, 35, 00054 38, 38, 40, 40, 40, 00055 48, 48, 46, 46, 00056 56, 56, 58, 00057 69, 69, 00058 83 00059 }; |
|
Definition at line 562 of file header.c. Referenced by mpeg2_header_extension().
00563 {
00564 return 0;
00565 }
|
|
Definition at line 252 of file header.c. References sequence_t::byte_rate, sequence_t::display_height, sequence_t::display_width, sequence_t::flags, sequence_t::pixel_height, sequence_t::pixel_width, and SEQ_FLAG_MPEG2. Referenced by mpeg2_header_sequence_finalize().
00253 { 00254 int width; 00255 int height; 00256 00257 sequence->byte_rate *= 50; 00258 00259 if (sequence->flags & SEQ_FLAG_MPEG2) { 00260 switch (sequence->pixel_width) { 00261 case 1: /* square pixels */ 00262 sequence->pixel_width = sequence->pixel_height = 1; return; 00263 case 2: /* 4:3 aspect ratio */ 00264 width = 4; height = 3; break; 00265 case 3: /* 16:9 aspect ratio */ 00266 width = 16; height = 9; break; 00267 case 4: /* 2.21:1 aspect ratio */ 00268 width = 221; height = 100; break; 00269 default: /* illegal */ 00270 sequence->pixel_width = sequence->pixel_height = 0; return; 00271 } 00272 width *= sequence->display_height; 00273 height *= sequence->display_width; 00274 00275 } else { 00276 if (sequence->byte_rate == 50 * 0x3ffff) 00277 sequence->byte_rate = 0; /* mpeg-1 VBR */ 00278 00279 switch (sequence->pixel_width) { 00280 case 0: case 15: /* illegal */ 00281 sequence->pixel_width = sequence->pixel_height = 0; return; 00282 case 1: /* square pixels */ 00283 sequence->pixel_width = sequence->pixel_height = 1; return; 00284 case 3: /* 720x576 16:9 */ 00285 sequence->pixel_width = 64; sequence->pixel_height = 45; return; 00286 case 6: /* 720x480 16:9 */ 00287 sequence->pixel_width = 32; sequence->pixel_height = 27; return; 00288 case 12: /* 720*480 4:3 */ 00289 sequence->pixel_width = 8; sequence->pixel_height = 9; return; 00290 default: 00291 height = 88 * sequence->pixel_width + 1171; 00292 width = 2000; 00293 } 00294 } 00295 00296 sequence->pixel_width = width; 00297 sequence->pixel_height = height; 00298 while (width) { /* find greatest common divisor */ 00299 int tmp = width; 00300 width = height % tmp; 00301 height = tmp; 00302 } 00303 sequence->pixel_width /= height; 00304 sequence->pixel_height /= height; 00305 } |
|
|
Definition at line 588 of file header.c. References mpeg2dec_s::chunk_start, copyright_ext(), mpeg2dec_s::ext_state, picture_coding_ext(), picture_display_ext(), quant_matrix_ext(), sequence_display_ext(), and sequence_ext().
00589 { 00590 static int (* parser[]) (mpeg2dec_t *) = { 00591 0, sequence_ext, sequence_display_ext, quant_matrix_ext, 00592 copyright_ext, 0, 0, picture_display_ext, picture_coding_ext 00593 }; 00594 int ext, ext_bit; 00595 00596 ext = mpeg2dec->chunk_start[0] >> 4; 00597 ext_bit = 1 << ext; 00598 00599 if (!(mpeg2dec->ext_state & ext_bit)) 00600 return 0; /* ignore illegal extensions */ 00601 mpeg2dec->ext_state &= ~ext_bit; 00602 return parser[ext] (mpeg2dec); 00603 } |
|
Definition at line 328 of file header.c. References mpeg2dec_s::info, reset_info(), mpeg2dec_s::state, and STATE_GOP.
00329 { 00330 mpeg2dec->state = STATE_GOP; 00331 reset_info (&(mpeg2dec->info)); 00332 return 0; 00333 } |
|
Definition at line 389 of file header.c. References ALLOC_CONVERTED, mpeg2dec_s::alloc_index, ALLOC_YUV, decoder_s::b_motion, fbuf_t::buf, mpeg2dec_s::chunk_start, decoder_s::coding_type, mpeg2dec_s::convert_size, mpeg2dec_s::convert_start, mpeg2_info_t::current_picture, mpeg2_info_t::current_picture_2nd, mpeg2dec_s::custom_fbuf, mpeg2dec_s::decoder, mpeg2_info_t::discard_fbuf, mpeg2_info_t::display_fbuf, mpeg2_info_t::display_picture, mpeg2_info_t::display_picture_2nd, mpeg2dec_s::ext_state, motion_t::f_code, decoder_s::f_motion, mpeg2dec_s::fbuf, mpeg2dec_s::fbuf_alloc, mpeg2dec_s::first, sequence_t::flags, picture_t::flags, decoder_s::height, fbuf_t::id, mpeg2dec_s::info, mpeg2_malloc(), mpeg2_set_fbuf(), picture_t::nb_fields, PIC_CODING_EXT, PIC_FLAG_CODING_TYPE_B, PIC_FLAG_CODING_TYPE_P, mpeg2dec_s::picture, mpeg2dec_s::pictures, reset_info(), decoder_s::second_field, SEQ_FLAG_LOW_DELAY, mpeg2dec_s::sequence, mpeg2dec_s::state, STATE_PICTURE, picture_t::temporal_reference, uint8_t, mpeg2_info_t::user_data, mpeg2_info_t::user_data_len, and decoder_s::width.
00390 { 00391 uint8_t * buffer = mpeg2dec->chunk_start; 00392 picture_t * picture = mpeg2dec->picture; 00393 decoder_t * decoder = &(mpeg2dec->decoder); 00394 int type; 00395 int low_delay; 00396 00397 type = (buffer [1] >> 3) & 7; 00398 low_delay = mpeg2dec->sequence.flags & SEQ_FLAG_LOW_DELAY; 00399 00400 if (mpeg2dec->state == STATE_PICTURE) { 00401 picture_t * other; 00402 00403 decoder->second_field = 0; 00404 other = mpeg2dec->pictures; 00405 if (other == picture) 00406 other += 2; 00407 if (decoder->coding_type != PIC_FLAG_CODING_TYPE_B) { 00408 mpeg2dec->fbuf[2] = mpeg2dec->fbuf[1]; 00409 mpeg2dec->fbuf[1] = mpeg2dec->fbuf[0]; 00410 } 00411 mpeg2dec->fbuf[0] = NULL; 00412 reset_info (&(mpeg2dec->info)); 00413 mpeg2dec->info.current_picture = picture; 00414 mpeg2dec->info.display_picture = picture; 00415 if (type != PIC_FLAG_CODING_TYPE_B) { 00416 if (!low_delay) { 00417 if (mpeg2dec->first) { 00418 mpeg2dec->info.display_picture = NULL; 00419 mpeg2dec->first = 0; 00420 } else { 00421 mpeg2dec->info.display_picture = other; 00422 if (other->nb_fields == 1) 00423 mpeg2dec->info.display_picture_2nd = other + 1; 00424 mpeg2dec->info.display_fbuf = mpeg2dec->fbuf[1]; 00425 } 00426 } 00427 if (!low_delay + !mpeg2dec->convert_start) 00428 mpeg2dec->info.discard_fbuf = 00429 mpeg2dec->fbuf[!low_delay + !mpeg2dec->convert_start]; 00430 } 00431 if (!mpeg2dec->custom_fbuf) { 00432 while (mpeg2dec->alloc_index < 3) { 00433 fbuf_t * fbuf; 00434 00435 fbuf = &(mpeg2dec->fbuf_alloc[mpeg2dec->alloc_index++].fbuf); 00436 fbuf->id = NULL; 00437 if (mpeg2dec->convert_start) { 00438 fbuf->buf[0] = 00439 (uint8_t *) mpeg2_malloc (mpeg2dec->convert_size[0], 00440 ALLOC_CONVERTED); 00441 fbuf->buf[1] = fbuf->buf[0] + mpeg2dec->convert_size[1]; 00442 fbuf->buf[2] = fbuf->buf[0] + mpeg2dec->convert_size[2]; 00443 } else { 00444 int size; 00445 size = mpeg2dec->decoder.width * mpeg2dec->decoder.height; 00446 fbuf->buf[0] = (uint8_t *) mpeg2_malloc (6 * size >> 2, 00447 ALLOC_YUV); 00448 fbuf->buf[1] = fbuf->buf[0] + size; 00449 fbuf->buf[2] = fbuf->buf[1] + (size >> 2); 00450 } 00451 } 00452 mpeg2_set_fbuf (mpeg2dec, type); 00453 } 00454 } else { 00455 decoder->second_field = 1; 00456 mpeg2dec->info.current_picture_2nd = picture; 00457 mpeg2dec->info.user_data = NULL; mpeg2dec->info.user_data_len = 0; 00458 if (low_delay || type == PIC_FLAG_CODING_TYPE_B) 00459 mpeg2dec->info.display_picture_2nd = picture; 00460 } 00461 mpeg2dec->ext_state = PIC_CODING_EXT; 00462 00463 picture->temporal_reference = (buffer[0] << 2) | (buffer[1] >> 6); 00464 00465 decoder->coding_type = type; 00466 picture->flags |= type; 00467 00468 if (type == PIC_FLAG_CODING_TYPE_P || type == PIC_FLAG_CODING_TYPE_B) { 00469 /* forward_f_code and backward_f_code - used in mpeg1 only */ 00470 decoder->f_motion.f_code[1] = (buffer[3] >> 2) & 1; 00471 decoder->f_motion.f_code[0] = 00472 (((buffer[3] << 1) | (buffer[4] >> 7)) & 7) - 1; 00473 decoder->b_motion.f_code[1] = (buffer[4] >> 6) & 1; 00474 decoder->b_motion.f_code[0] = ((buffer[4] >> 3) & 7) - 1; 00475 } 00476 00477 /* XXXXXX decode extra_information_picture as well */ 00478 00479 picture->nb_fields = 2; 00480 00481 return 0; 00482 } |
|
Definition at line 354 of file header.c. References mpeg2dec_s::bytes_since_pts, decoder_s::coding_type, mpeg2dec_s::decoder, picture_t::display_offset, mpeg2dec_s::display_offset_x, mpeg2dec_s::display_offset_y, picture_t::flags, mpeg2_parse_header(), mpeg2dec_s::num_pts, PIC_FLAG_CODING_TYPE_B, PIC_FLAG_PTS, mpeg2dec_s::picture, mpeg2dec_s::pictures, picture_t::pts, mpeg2dec_s::pts_current, mpeg2dec_s::pts_previous, mpeg2dec_s::state, STATE_PICTURE, STATE_PICTURE_2ND, and STATE_SLICE_1ST.
00355 { 00356 decoder_t * decoder = &(mpeg2dec->decoder); 00357 picture_t * picture; 00358 00359 if (mpeg2dec->state != STATE_SLICE_1ST) { 00360 mpeg2dec->state = STATE_PICTURE; 00361 picture = mpeg2dec->pictures; 00362 if ((decoder->coding_type != PIC_FLAG_CODING_TYPE_B) ^ 00363 (mpeg2dec->picture >= mpeg2dec->pictures + 2)) 00364 picture += 2; 00365 } else { 00366 mpeg2dec->state = STATE_PICTURE_2ND; 00367 picture = mpeg2dec->picture + 1; /* second field picture */ 00368 } 00369 mpeg2dec->picture = picture; 00370 picture->flags = 0; 00371 if (mpeg2dec->num_pts) { 00372 if (mpeg2dec->bytes_since_pts >= 4) { 00373 mpeg2dec->num_pts = 0; 00374 picture->pts = mpeg2dec->pts_current; 00375 picture->flags = PIC_FLAG_PTS; 00376 } else if (mpeg2dec->num_pts > 1) { 00377 mpeg2dec->num_pts = 1; 00378 picture->pts = mpeg2dec->pts_previous; 00379 picture->flags = PIC_FLAG_PTS; 00380 } 00381 } 00382 picture->display_offset[0].x = picture->display_offset[1].x = 00383 picture->display_offset[2].x = mpeg2dec->display_offset_x; 00384 picture->display_offset[0].y = picture->display_offset[1].y = 00385 picture->display_offset[2].y = mpeg2dec->display_offset_y; 00386 return mpeg2_parse_header (mpeg2dec); 00387 } |
|
Definition at line 97 of file header.c. References sequence_t::byte_rate, sequence_t::chroma_height, sequence_t::chroma_width, mpeg2dec_s::chunk_start, sequence_t::colour_primaries, decoder_s::concealment_motion_vectors, mpeg2dec_s::decoder, sequence_t::display_height, mpeg2dec_s::display_offset_x, mpeg2dec_s::display_offset_y, sequence_t::display_width, mpeg2dec_s::ext_state, sequence_t::flags, sequence_t::frame_period, FRAME_PICTURE, decoder_s::frame_pred_frame_dct, decoder_s::height, sequence_t::height, i, mpeg2dec_s::info, decoder_s::intra_dc_precision, decoder_s::intra_quantizer_matrix, sequence_t::matrix_coefficients, decoder_s::mpeg1, mpeg2dec_s::new_sequence, decoder_s::non_intra_quantizer_matrix, sequence_t::picture_height, decoder_s::picture_structure, sequence_t::picture_width, sequence_t::pixel_width, sequence_t::profile_level_id, decoder_s::q_scale_type, reset_info(), decoder_s::scan, SEQ_EXT, SEQ_FLAG_CONSTRAINED_PARAMETERS, SEQ_FLAG_PROGRESSIVE_SEQUENCE, mpeg2dec_s::state, STATE_SEQUENCE, sequence_t::transfer_characteristics, uint8_t, sequence_t::vbv_buffer_size, decoder_s::vertical_position_extension, decoder_s::width, and sequence_t::width.
00098 { 00099 uint8_t * buffer = mpeg2dec->chunk_start; 00100 sequence_t * sequence = &(mpeg2dec->new_sequence); 00101 decoder_t * decoder = &(mpeg2dec->decoder); 00102 static unsigned int frame_period[9] = { 00103 0, 1126125, 1125000, 1080000, 900900, 900000, 540000, 450450, 450000 00104 }; 00105 int width, height; 00106 int i; 00107 00108 if ((buffer[6] & 0x20) != 0x20) /* missing marker_bit */ 00109 return 1; 00110 00111 i = (buffer[0] << 16) | (buffer[1] << 8) | buffer[2]; 00112 sequence->display_width = sequence->picture_width = width = i >> 12; 00113 sequence->display_height = sequence->picture_height = height = i & 0xfff; 00114 decoder->width = sequence->width = width = (width + 15) & ~15; 00115 decoder->height = sequence->height = height = (height + 15) & ~15; 00116 decoder->vertical_position_extension = (height > 2800); 00117 sequence->chroma_width = width >> 1; 00118 sequence->chroma_height = height >> 1; 00119 00120 sequence->flags = SEQ_FLAG_PROGRESSIVE_SEQUENCE; 00121 00122 sequence->pixel_width = buffer[3] >> 4; /* aspect ratio */ 00123 sequence->frame_period = 0; 00124 if ((buffer[3] & 15) < 9) 00125 sequence->frame_period = frame_period[buffer[3] & 15]; 00126 00127 sequence->byte_rate = (buffer[4]<<10) | (buffer[5]<<2) | (buffer[6]>>6); 00128 00129 sequence->vbv_buffer_size = ((buffer[6]<<16)|(buffer[7]<<8))&0x1ff800; 00130 00131 if (buffer[7] & 4) 00132 sequence->flags |= SEQ_FLAG_CONSTRAINED_PARAMETERS; 00133 00134 if (buffer[7] & 2) { 00135 for (i = 0; i < 64; i++) 00136 decoder->intra_quantizer_matrix[mpeg2_scan_norm[i]] = 00137 (buffer[i+7] << 7) | (buffer[i+8] >> 1); 00138 buffer += 64; 00139 } else 00140 for (i = 0; i < 64; i++) 00141 decoder->intra_quantizer_matrix[mpeg2_scan_norm[i]] = 00142 default_intra_quantizer_matrix [i]; 00143 00144 if (buffer[7] & 1) 00145 for (i = 0; i < 64; i++) 00146 decoder->non_intra_quantizer_matrix[mpeg2_scan_norm[i]] = 00147 buffer[i+8]; 00148 else 00149 for (i = 0; i < 64; i++) 00150 decoder->non_intra_quantizer_matrix[i] = 16; 00151 00152 sequence->profile_level_id = 0x80; 00153 sequence->colour_primaries = 1; 00154 sequence->transfer_characteristics = 1; 00155 sequence->matrix_coefficients = 1; 00156 00157 decoder->mpeg1 = 1; 00158 decoder->intra_dc_precision = 0; 00159 decoder->frame_pred_frame_dct = 1; 00160 decoder->q_scale_type = 0; 00161 decoder->concealment_motion_vectors = 0; 00162 decoder->scan = mpeg2_scan_norm; 00163 decoder->picture_structure = FRAME_PICTURE; 00164 00165 mpeg2dec->ext_state = SEQ_EXT; 00166 mpeg2dec->state = STATE_SEQUENCE; 00167 mpeg2dec->display_offset_x = mpeg2dec->display_offset_y = 0; 00168 00169 reset_info (&(mpeg2dec->info)); 00170 return 0; 00171 } |
|
Definition at line 307 of file header.c. References sequence_t::byte_rate, finalize_sequence(), mpeg2dec_s::info, memcmp(), mpeg2dec_s::new_sequence, mpeg2dec_s::sequence, mpeg2_info_t::sequence, mpeg2dec_s::state, and STATE_SEQUENCE_REPEATED. Referenced by mpeg2_parse_header().
00308 { 00309 sequence_t * sequence = &(mpeg2dec->new_sequence); 00310 00311 finalize_sequence (sequence); 00312 00313 /* 00314 * according to 6.1.1.6, repeat sequence headers should be 00315 * identical to the original. However some DVDs dont respect that 00316 * and have different bitrates in the repeat sequence headers. So 00317 * we'll ignore that in the comparison and still consider these as 00318 * repeat sequence headers. 00319 */ 00320 mpeg2dec->sequence.byte_rate = sequence->byte_rate; 00321 if (!memcmp (&(mpeg2dec->sequence), sequence, sizeof (sequence_t))) 00322 mpeg2dec->state = STATE_SEQUENCE_REPEATED; 00323 mpeg2dec->sequence = *sequence; 00324 00325 mpeg2dec->info.sequence = &(mpeg2dec->sequence); 00326 } |
|
|
Definition at line 77 of file header.c. References mpeg2dec_s::alloc_index, mpeg2dec_s::alloc_index_user, mpeg2dec_s::decoder, mpeg2dec_s::fbuf, fbuf_alloc_t::fbuf, mpeg2dec_s::fbuf_alloc, mpeg2dec_s::first, mpeg2dec_s::picture, mpeg2dec_s::pictures, and decoder_s::scan. Referenced by mpeg2_init().
00078 { 00079 mpeg2dec->decoder.scan = mpeg2_scan_norm; 00080 mpeg2dec->picture = mpeg2dec->pictures; 00081 mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[0].fbuf; 00082 mpeg2dec->fbuf[1] = &mpeg2dec->fbuf_alloc[1].fbuf; 00083 mpeg2dec->fbuf[2] = &mpeg2dec->fbuf_alloc[2].fbuf; 00084 mpeg2dec->first = 1; 00085 mpeg2dec->alloc_index = 0; 00086 mpeg2dec->alloc_index_user = 0; 00087 } |
|
Definition at line 605 of file header.c. References mpeg2dec_s::chunk_ptr, mpeg2dec_s::chunk_start, mpeg2dec_s::info, mpeg2_info_t::user_data, and mpeg2_info_t::user_data_len.
00606 { 00607 if (!mpeg2dec->info.user_data_len) 00608 mpeg2dec->info.user_data = mpeg2dec->chunk_start; 00609 else 00610 mpeg2dec->info.user_data_len += 3; 00611 mpeg2dec->info.user_data_len += (mpeg2dec->chunk_ptr - 4 - 00612 mpeg2dec->chunk_start); 00613 mpeg2dec->chunk_start = mpeg2dec->chunk_ptr - 1; 00614 00615 return 0; 00616 } |
|
Definition at line 335 of file header.c. References B_TYPE, mpeg2dec_s::convert_start, mpeg2_info_t::current_fbuf, mpeg2_info_t::discard_fbuf, mpeg2_info_t::display_fbuf, mpeg2dec_s::fbuf, mpeg2dec_s::fbuf_alloc, sequence_t::flags, i, mpeg2dec_s::info, SEQ_FLAG_LOW_DELAY, and mpeg2dec_s::sequence. Referenced by mpeg2_header_picture(), and mpeg2_set_buf().
00336 { 00337 int i; 00338 00339 for (i = 0; i < 3; i++) 00340 if (mpeg2dec->fbuf[1] != &mpeg2dec->fbuf_alloc[i].fbuf && 00341 mpeg2dec->fbuf[2] != &mpeg2dec->fbuf_alloc[i].fbuf) { 00342 mpeg2dec->fbuf[0] = &mpeg2dec->fbuf_alloc[i].fbuf; 00343 mpeg2dec->info.current_fbuf = mpeg2dec->fbuf[0]; 00344 if ((coding_type == B_TYPE) || 00345 (mpeg2dec->sequence.flags & SEQ_FLAG_LOW_DELAY)) { 00346 if ((coding_type == B_TYPE) || (mpeg2dec->convert_start)) 00347 mpeg2dec->info.discard_fbuf = mpeg2dec->fbuf[0]; 00348 mpeg2dec->info.display_fbuf = mpeg2dec->fbuf[0]; 00349 } 00350 break; 00351 } 00352 } |
|
Definition at line 484 of file header.c. References decoder_s::b_motion, BOTTOM_FIELD, mpeg2dec_s::chunk_start, decoder_s::concealment_motion_vectors, COPYRIGHT_EXT, mpeg2dec_s::decoder, mpeg2dec_s::ext_state, motion_t::f_code, decoder_s::f_motion, sequence_t::flags, picture_t::flags, flags, FRAME_PICTURE, decoder_s::frame_pred_frame_dct, decoder_s::intra_dc_precision, decoder_s::intra_vlc_format, picture_t::nb_fields, PIC_DISPLAY_EXT, PIC_FLAG_COMPOSITE_DISPLAY, PIC_FLAG_PROGRESSIVE_FRAME, PIC_FLAG_TOP_FIELD_FIRST, PIC_MASK_COMPOSITE_DISPLAY, mpeg2dec_s::picture, decoder_s::picture_structure, decoder_s::q_scale_type, QUANT_MATRIX_EXT, decoder_s::scan, SEQ_FLAG_PROGRESSIVE_SEQUENCE, mpeg2dec_s::sequence, TOP_FIELD, decoder_s::top_field_first, uint32_t, and uint8_t. Referenced by mpeg2_header_extension().
00485 { 00486 uint8_t * buffer = mpeg2dec->chunk_start; 00487 picture_t * picture = mpeg2dec->picture; 00488 decoder_t * decoder = &(mpeg2dec->decoder); 00489 uint32_t flags; 00490 00491 /* pre subtract 1 for use later in compute_motion_vector */ 00492 decoder->f_motion.f_code[0] = (buffer[0] & 15) - 1; 00493 decoder->f_motion.f_code[1] = (buffer[1] >> 4) - 1; 00494 decoder->b_motion.f_code[0] = (buffer[1] & 15) - 1; 00495 decoder->b_motion.f_code[1] = (buffer[2] >> 4) - 1; 00496 00497 flags = picture->flags; 00498 decoder->intra_dc_precision = (buffer[2] >> 2) & 3; 00499 decoder->picture_structure = buffer[2] & 3; 00500 switch (decoder->picture_structure) { 00501 case TOP_FIELD: 00502 flags |= PIC_FLAG_TOP_FIELD_FIRST; 00503 case BOTTOM_FIELD: 00504 picture->nb_fields = 1; 00505 break; 00506 case FRAME_PICTURE: 00507 if (!(mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE)) { 00508 picture->nb_fields = (buffer[3] & 2) ? 3 : 2; 00509 flags |= (buffer[3] & 128) ? PIC_FLAG_TOP_FIELD_FIRST : 0; 00510 } else 00511 picture->nb_fields = (buffer[3]&2) ? ((buffer[3]&128) ? 6 : 4) : 2; 00512 break; 00513 default: 00514 return 1; 00515 } 00516 decoder->top_field_first = buffer[3] >> 7; 00517 decoder->frame_pred_frame_dct = (buffer[3] >> 6) & 1; 00518 decoder->concealment_motion_vectors = (buffer[3] >> 5) & 1; 00519 decoder->q_scale_type = (buffer[3] >> 4) & 1; 00520 decoder->intra_vlc_format = (buffer[3] >> 3) & 1; 00521 decoder->scan = (buffer[3] & 4) ? mpeg2_scan_alt : mpeg2_scan_norm; 00522 flags |= (buffer[4] & 0x80) ? PIC_FLAG_PROGRESSIVE_FRAME : 0; 00523 if (buffer[4] & 0x40) 00524 flags |= (((buffer[4]<<26) | (buffer[5]<<18) | (buffer[6]<<10)) & 00525 PIC_MASK_COMPOSITE_DISPLAY) | PIC_FLAG_COMPOSITE_DISPLAY; 00526 picture->flags = flags; 00527 00528 mpeg2dec->ext_state = PIC_DISPLAY_EXT | COPYRIGHT_EXT | QUANT_MATRIX_EXT; 00529 00530 return 0; 00531 } |
|
Definition at line 533 of file header.c. References mpeg2dec_s::chunk_start, picture_t::display_offset, mpeg2dec_s::display_offset_x, mpeg2dec_s::display_offset_y, sequence_t::flags, i, picture_t::nb_fields, mpeg2dec_s::picture, SEQ_FLAG_PROGRESSIVE_SEQUENCE, mpeg2dec_s::sequence, and uint8_t. Referenced by mpeg2_header_extension().
00534 { 00535 uint8_t * buffer = mpeg2dec->chunk_start; 00536 picture_t * picture = mpeg2dec->picture; 00537 int i, nb_pos; 00538 00539 nb_pos = picture->nb_fields; 00540 if (mpeg2dec->sequence.flags & SEQ_FLAG_PROGRESSIVE_SEQUENCE) 00541 nb_pos >>= 1; 00542 00543 for (i = 0; i < nb_pos; i++) { 00544 int x, y; 00545 00546 x = ((buffer[4*i] << 24) | (buffer[4*i+1] << 16) | 00547 (buffer[4*i+2] << 8) | buffer[4*i+3]) >> (11-2*i); 00548 y = ((buffer[4*i+2] << 24) | (buffer[4*i+3] << 16) | 00549 (buffer[4*i+4] << 8) | buffer[4*i+5]) >> (10-2*i); 00550 if (! (x & y & 1)) 00551 return 1; 00552 picture->display_offset[i].x = mpeg2dec->display_offset_x = x >> 1; 00553 picture->display_offset[i].y = mpeg2dec->display_offset_y = y >> 1; 00554 } 00555 for (; i < 3; i++) { 00556 picture->display_offset[i].x = mpeg2dec->display_offset_x; 00557 picture->display_offset[i].y = mpeg2dec->display_offset_y; 00558 } 00559 return 0; 00560 } |
|
Definition at line 567 of file header.c. References mpeg2dec_s::chunk_start, mpeg2dec_s::decoder, i, decoder_s::intra_quantizer_matrix, decoder_s::non_intra_quantizer_matrix, and uint8_t. Referenced by mpeg2_header_extension().
00568 { 00569 uint8_t * buffer = mpeg2dec->chunk_start; 00570 decoder_t * decoder = &(mpeg2dec->decoder); 00571 int i; 00572 00573 if (buffer[0] & 8) { 00574 for (i = 0; i < 64; i++) 00575 decoder->intra_quantizer_matrix[mpeg2_scan_norm[i]] = 00576 (buffer[i] << 5) | (buffer[i+1] >> 3); 00577 buffer += 64; 00578 } 00579 00580 if (buffer[0] & 4) 00581 for (i = 0; i < 64; i++) 00582 decoder->non_intra_quantizer_matrix[mpeg2_scan_norm[i]] = 00583 (buffer[i] << 6) | (buffer[i+1] >> 2); 00584 00585 return 0; 00586 } |
|
Definition at line 89 of file header.c. References mpeg2_info_t::current_fbuf, mpeg2_info_t::current_picture, mpeg2_info_t::current_picture_2nd, mpeg2_info_t::discard_fbuf, mpeg2_info_t::display_fbuf, mpeg2_info_t::display_picture, mpeg2_info_t::display_picture_2nd, mpeg2_info_t::user_data, and mpeg2_info_t::user_data_len. Referenced by mpeg2_header_end(), mpeg2_header_gop(), mpeg2_header_picture(), and mpeg2_header_sequence().
00090 { 00091 info->current_picture = info->current_picture_2nd = NULL; 00092 info->display_picture = info->display_picture_2nd = NULL; 00093 info->current_fbuf = info->display_fbuf = info->discard_fbuf = NULL; 00094 info->user_data = NULL; info->user_data_len = 0; 00095 } |
|
Definition at line 226 of file header.c. References mpeg2dec_s::chunk_start, sequence_t::colour_primaries, sequence_t::display_height, sequence_t::display_width, sequence_t::flags, flags, sequence_t::matrix_coefficients, mpeg2dec_s::new_sequence, SEQ_FLAG_COLOUR_DESCRIPTION, SEQ_MASK_VIDEO_FORMAT, sequence_t::transfer_characteristics, uint32_t, and uint8_t. Referenced by mpeg2_header_extension().
00227 { 00228 uint8_t * buffer = mpeg2dec->chunk_start; 00229 sequence_t * sequence = &(mpeg2dec->new_sequence); 00230 uint32_t flags; 00231 00232 flags = ((sequence->flags & ~SEQ_MASK_VIDEO_FORMAT) | 00233 ((buffer[0]<<4) & SEQ_MASK_VIDEO_FORMAT)); 00234 if (buffer[0] & 1) { 00235 flags |= SEQ_FLAG_COLOUR_DESCRIPTION; 00236 sequence->colour_primaries = buffer[1]; 00237 sequence->transfer_characteristics = buffer[2]; 00238 sequence->matrix_coefficients = buffer[3]; 00239 buffer += 3; 00240 } 00241 00242 if (!(buffer[2] & 2)) /* missing marker_bit */ 00243 return 1; 00244 00245 sequence->display_width = (buffer[1] << 6) | (buffer[2] >> 2); 00246 sequence->display_height = 00247 ((buffer[2]& 1 ) << 13) | (buffer[3] << 5) | (buffer[4] >> 3); 00248 00249 return 0; 00250 } |
|
Definition at line 173 of file header.c. References sequence_t::byte_rate, sequence_t::chroma_height, sequence_t::chroma_width, mpeg2dec_s::chunk_start, mpeg2dec_s::decoder, sequence_t::display_height, sequence_t::display_width, mpeg2dec_s::ext_state, sequence_t::flags, flags, sequence_t::frame_period, sequence_t::height, decoder_s::height, decoder_s::mpeg1, mpeg2dec_s::new_sequence, sequence_t::picture_height, sequence_t::picture_width, sequence_t::profile_level_id, SEQ_DISPLAY_EXT, SEQ_FLAG_LOW_DELAY, SEQ_FLAG_MPEG2, SEQ_FLAG_PROGRESSIVE_SEQUENCE, uint32_t, uint8_t, sequence_t::vbv_buffer_size, decoder_s::vertical_position_extension, sequence_t::width, and decoder_s::width. Referenced by mpeg2_header_extension().
00174 { 00175 uint8_t * buffer = mpeg2dec->chunk_start; 00176 sequence_t * sequence = &(mpeg2dec->new_sequence); 00177 decoder_t * decoder = &(mpeg2dec->decoder); 00178 int width, height; 00179 uint32_t flags; 00180 00181 if (!(buffer[3] & 1)) 00182 return 1; 00183 00184 sequence->profile_level_id = (buffer[0] << 4) | (buffer[1] >> 4); 00185 00186 width = sequence->display_width = sequence->picture_width += 00187 ((buffer[1] << 13) | (buffer[2] << 5)) & 0x3000; 00188 height = sequence->display_height = sequence->picture_height += 00189 (buffer[2] << 7) & 0x3000; 00190 decoder->vertical_position_extension = (height > 2800); 00191 flags = sequence->flags | SEQ_FLAG_MPEG2; 00192 if (!(buffer[1] & 8)) { 00193 flags &= ~SEQ_FLAG_PROGRESSIVE_SEQUENCE; 00194 height = (height + 31) & ~31; 00195 } 00196 if (buffer[5] & 0x80) 00197 flags |= SEQ_FLAG_LOW_DELAY; 00198 sequence->flags = flags; 00199 decoder->width = sequence->width = width = (width + 15) & ~15; 00200 decoder->height = sequence->height = height = (height + 15) & ~15; 00201 switch (buffer[1] & 6) { 00202 case 0: /* invalid */ 00203 return 1; 00204 case 2: /* 4:2:0 */ 00205 height >>= 1; 00206 case 4: /* 4:2:2 */ 00207 width >>= 1; 00208 } 00209 sequence->chroma_width = width; 00210 sequence->chroma_height = height; 00211 00212 sequence->byte_rate += ((buffer[2]<<25) | (buffer[3]<<17)) & 0x3ffc0000; 00213 00214 sequence->vbv_buffer_size |= buffer[4] << 21; 00215 00216 sequence->frame_period = 00217 sequence->frame_period * ((buffer[5]&31)+1) / (((buffer[5]>>2)&3)+1); 00218 00219 decoder->mpeg1 = 0; 00220 00221 mpeg2dec->ext_state = SEQ_DISPLAY_EXT; 00222 00223 return 0; 00224 } |