+ if (nal.type == H264_NAL_IDR_SLICE)
+ get_ue_golomb(&nal.gb); /* idr_pic_id */
+ if (sps->poc_type == 0) {
+ p->poc.poc_lsb = get_bits(&nal.gb, sps->log2_max_poc_lsb);
+
+ if (p->ps.pps->pic_order_present == 1 &&
+ p->picture_structure == PICT_FRAME)
+ p->poc.delta_poc_bottom = get_se_golomb(&nal.gb);
+ }
+
+ if (sps->poc_type == 1 &&
+ !sps->delta_pic_order_always_zero_flag) {
+ p->poc.delta_poc[0] = get_se_golomb(&nal.gb);
+
+ if (p->ps.pps->pic_order_present == 1 &&
+ p->picture_structure == PICT_FRAME)
+ p->poc.delta_poc[1] = get_se_golomb(&nal.gb);
+ }
+
+ /* Decode POC of this picture.
+ * The prev_ values needed for decoding POC of the next picture are not set here. */
+ field_poc[0] = field_poc[1] = INT_MAX;
+ ff_h264_init_poc(field_poc, &s->output_picture_number, sps,
+ &p->poc, p->picture_structure, nal.ref_idc);
+
+ /* Continue parsing to check if MMCO_RESET is present.
+ * FIXME: MMCO_RESET could appear in non-first slice.
+ * Maybe, we should parse all undisposable non-IDR slice of this
+ * picture until encountering MMCO_RESET in a slice of it. */
+ if (nal.ref_idc && nal.type != H264_NAL_IDR_SLICE) {
+ got_reset = scan_mmco_reset(s, &nal.gb, avctx);
+ if (got_reset < 0)
+ goto fail;
+ }
+
+ /* Set up the prev_ values for decoding POC of the next picture. */
+ p->poc.prev_frame_num = got_reset ? 0 : p->poc.frame_num;
+ p->poc.prev_frame_num_offset = got_reset ? 0 : p->poc.frame_num_offset;
+ if (nal.ref_idc != 0) {
+ if (!got_reset) {
+ p->poc.prev_poc_msb = p->poc.poc_msb;
+ p->poc.prev_poc_lsb = p->poc.poc_lsb;
+ } else {
+ p->poc.prev_poc_msb = 0;
+ p->poc.prev_poc_lsb =
+ p->picture_structure == PICT_BOTTOM_FIELD ? 0 : field_poc[0];
+ }
+ }
+
+ if (sps->pic_struct_present_flag && p->sei.picture_timing.present) {
+ switch (p->sei.picture_timing.pic_struct) {
+ case H264_SEI_PIC_STRUCT_TOP_FIELD:
+ case H264_SEI_PIC_STRUCT_BOTTOM_FIELD:
+ s->repeat_pict = 0;
+ break;
+ case H264_SEI_PIC_STRUCT_FRAME:
+ case H264_SEI_PIC_STRUCT_TOP_BOTTOM:
+ case H264_SEI_PIC_STRUCT_BOTTOM_TOP:
+ s->repeat_pict = 1;
+ break;
+ case H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
+ case H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
+ s->repeat_pict = 2;
+ break;
+ case H264_SEI_PIC_STRUCT_FRAME_DOUBLING:
+ s->repeat_pict = 3;
+ break;
+ case H264_SEI_PIC_STRUCT_FRAME_TRIPLING:
+ s->repeat_pict = 5;
+ break;
+ default:
+ s->repeat_pict = p->picture_structure == PICT_FRAME ? 1 : 0;
+ break;
+ }
+ } else {
+ s->repeat_pict = p->picture_structure == PICT_FRAME ? 1 : 0;
+ }
+
+ if (p->picture_structure == PICT_FRAME) {
+ s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
+ if (sps->pic_struct_present_flag && p->sei.picture_timing.present) {
+ switch (p->sei.picture_timing.pic_struct) {
+ case H264_SEI_PIC_STRUCT_TOP_BOTTOM:
+ case H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
+ s->field_order = AV_FIELD_TT;