~ppsspp/ppsspp/ffmpeg

« back to all changes in this revision

Viewing changes to libavcodec/h264_refs.c

  • Committer: Henrik Rydgård
  • Date: 2014-01-03 10:44:32 UTC
  • Revision ID: git-v1:87c6c126784b1718bfa448ecf2e6a9fef781eb4e
Update our ffmpeg snapshot to a clone of the official repository.

This is because Maxim's at3plus support has been officially merged!

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
    return match;
69
69
}
70
70
 
71
 
static int build_def_list(Picture *def, Picture **in, int len, int is_long, int sel)
 
71
static int build_def_list(Picture *def, int def_len,
 
72
                          Picture **in, int len, int is_long, int sel)
72
73
{
73
74
    int  i[2] = { 0 };
74
75
    int index = 0;
79
80
        while (i[1] < len && !(in[i[1]] && (in[i[1]]->reference & (sel ^ 3))))
80
81
            i[1]++;
81
82
        if (i[0] < len) {
 
83
            av_assert0(index < def_len);
82
84
            in[i[0]]->pic_id = is_long ? i[0] : in[i[0]]->frame_num;
83
85
            split_field_copy(&def[index++], in[i[0]++], sel, 1);
84
86
        }
85
87
        if (i[1] < len) {
 
88
            av_assert0(index < def_len);
86
89
            in[i[1]]->pic_id = is_long ? i[1] : in[i[1]]->frame_num;
87
90
            split_field_copy(&def[index++], in[i[1]++], sel ^ 3, 0);
88
91
        }
131
134
            len  = add_sorted(sorted,       h->short_ref, h->short_ref_count, cur_poc, 1 ^ list);
132
135
            len += add_sorted(sorted + len, h->short_ref, h->short_ref_count, cur_poc, 0 ^ list);
133
136
            av_assert0(len <= 32);
134
 
            len  = build_def_list(h->default_ref_list[list],       sorted,      len, 0, h->picture_structure);
135
 
            len += build_def_list(h->default_ref_list[list] + len, h->long_ref, 16,  1, h->picture_structure);
 
137
 
 
138
            len  = build_def_list(h->default_ref_list[list], FF_ARRAY_ELEMS(h->default_ref_list[0]),
 
139
                                  sorted, len, 0, h->picture_structure);
 
140
            len += build_def_list(h->default_ref_list[list] + len,
 
141
                                  FF_ARRAY_ELEMS(h->default_ref_list[0]) - len,
 
142
                                  h->long_ref, 16, 1, h->picture_structure);
136
143
            av_assert0(len <= 32);
137
144
 
138
145
            if (len < h->ref_count[list])
141
148
        }
142
149
 
143
150
        if (lens[0] == lens[1] && lens[1] > 1) {
144
 
            for (i = 0; h->default_ref_list[0][i].f.data[0] == h->default_ref_list[1][i].f.data[0] && i < lens[0]; i++);
 
151
            for (i = 0; i < lens[0] &&
 
152
                        h->default_ref_list[0][i].f.buf[0]->buffer ==
 
153
                        h->default_ref_list[1][i].f.buf[0]->buffer; i++);
145
154
            if (i == lens[0]) {
146
155
                Picture tmp;
147
156
                COPY_PICTURE(&tmp, &h->default_ref_list[1][0]);
150
159
            }
151
160
        }
152
161
    } else {
153
 
        len  = build_def_list(h->default_ref_list[0],       h->short_ref, h->short_ref_count, 0, h->picture_structure);
154
 
        len += build_def_list(h->default_ref_list[0] + len, h-> long_ref, 16,                 1, h->picture_structure);
 
162
        len  = build_def_list(h->default_ref_list[0], FF_ARRAY_ELEMS(h->default_ref_list[0]),
 
163
                              h->short_ref, h->short_ref_count, 0, h->picture_structure);
 
164
        len += build_def_list(h->default_ref_list[0] + len,
 
165
                              FF_ARRAY_ELEMS(h->default_ref_list[0]) - len,
 
166
                              h-> long_ref, 16, 1, h->picture_structure);
155
167
        av_assert0(len <= 32);
 
168
 
156
169
        if (len < h->ref_count[0])
157
170
            memset(&h->default_ref_list[0][len], 0, sizeof(Picture) * (h->ref_count[0] - len));
158
171
    }
304
317
    }
305
318
    for (list = 0; list < h->list_count; list++) {
306
319
        for (index = 0; index < h->ref_count[list]; index++) {
307
 
            if (   !h->ref_list[list][index].f.data[0]
 
320
            if (   !h->ref_list[list][index].f.buf[0]
308
321
                || (!FIELD_PICTURE(h) && (h->ref_list[list][index].reference&3) != 3)) {
309
322
                int i;
310
323
                av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
311
324
                for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
312
325
                    h->last_pocs[i] = INT_MIN;
313
 
                if (h->default_ref_list[list][0].f.data[0]
 
326
                if (h->default_ref_list[list][0].f.buf[0]
314
327
                    && !(!FIELD_PICTURE(h) && (h->default_ref_list[list][0].reference&3) != 3))
315
328
                    COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]);
316
329
                else
562
575
int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count)
563
576
{
564
577
    int i, av_uninit(j);
 
578
    int pps_count;
565
579
    int current_ref_assigned = 0, err = 0;
566
580
    Picture *av_uninit(pic);
567
581
 
582
596
                if (mmco[i].opcode != MMCO_SHORT2LONG ||
583
597
                    !h->long_ref[mmco[i].long_arg]    ||
584
598
                    h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
585
 
                    av_log(h->avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
 
599
                    av_log(h->avctx, h->short_ref_count ? AV_LOG_ERROR : AV_LOG_DEBUG, "mmco: unref short failure\n");
586
600
                    err = AVERROR_INVALIDDATA;
587
601
                }
588
602
                continue;
732
746
    print_short_term(h);
733
747
    print_long_term(h);
734
748
 
735
 
    if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME) && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
736
 
        h->cur_pic_ptr->sync |= 1;
 
749
    pps_count = 0;
 
750
    for (i = 0; i < FF_ARRAY_ELEMS(h->pps_buffers); i++)
 
751
        pps_count += !!h->pps_buffers[i];
 
752
 
 
753
    if (   err >= 0
 
754
        && h->long_ref_count==0
 
755
        && (h->short_ref_count<=2 || h->pps.ref_count[0] <= 1 && h->pps.ref_count[1] <= 1 && pps_count == 1)
 
756
        && h->pps.ref_count[0]<=2 + (h->picture_structure != PICT_FRAME)
 
757
        && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
 
758
        h->cur_pic_ptr->recovered |= 1;
737
759
        if(!h->avctx->has_b_frames)
738
 
            h->sync = 2;
 
760
            h->frame_recovered |= FRAME_RECOVERED_SEI;
739
761
    }
740
762
 
741
763
    return (h->avctx->err_recognition & AV_EF_EXPLODE) ? err : 0;