* commit 'b51c7c6b8a5b35cfd06cb9655f9ec4c9f0ddd81b':
vaapi_h264: Fix frame_num after non-reference frames
Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
... | ... |
@@ -101,8 +101,8 @@ typedef struct VAAPIEncodeH264Context { |
101 | 101 |
int fixed_qp_p; |
102 | 102 |
int fixed_qp_b; |
103 | 103 |
|
104 |
+ int next_frame_num; |
|
104 | 105 |
int64_t idr_pic_count; |
105 |
- int64_t last_idr_frame; |
|
106 | 106 |
|
107 | 107 |
// Rate control configuration. |
108 | 108 |
struct { |
... | ... |
@@ -592,12 +592,17 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, |
592 | 592 |
|
593 | 593 |
if (pic->type == PICTURE_TYPE_IDR) { |
594 | 594 |
av_assert0(pic->display_order == pic->encode_order); |
595 |
- priv->last_idr_frame = pic->display_order; |
|
595 |
+ vpic->frame_num = 0; |
|
596 |
+ priv->next_frame_num = 1; |
|
596 | 597 |
} else { |
597 |
- av_assert0(pic->display_order > priv->last_idr_frame); |
|
598 |
+ vpic->frame_num = priv->next_frame_num; |
|
599 |
+ if (pic->type != PICTURE_TYPE_B) { |
|
600 |
+ // nal_ref_idc != 0 |
|
601 |
+ ++priv->next_frame_num; |
|
602 |
+ } |
|
598 | 603 |
} |
599 | 604 |
|
600 |
- vpic->frame_num = (pic->encode_order - priv->last_idr_frame) & |
|
605 |
+ vpic->frame_num = vpic->frame_num & |
|
601 | 606 |
((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1); |
602 | 607 |
|
603 | 608 |
vpic->CurrPic.picture_id = pic->recon_surface; |
... | ... |
@@ -608,10 +613,9 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, |
608 | 608 |
|
609 | 609 |
for (i = 0; i < pic->nb_refs; i++) { |
610 | 610 |
VAAPIEncodePicture *ref = pic->refs[i]; |
611 |
- av_assert0(ref && ref->encode_order >= priv->last_idr_frame); |
|
611 |
+ av_assert0(ref && ref->encode_order < pic->encode_order); |
|
612 | 612 |
vpic->ReferenceFrames[i].picture_id = ref->recon_surface; |
613 |
- vpic->ReferenceFrames[i].frame_idx = |
|
614 |
- ref->encode_order - priv->last_idr_frame; |
|
613 |
+ vpic->ReferenceFrames[i].frame_idx = ref->encode_order; |
|
615 | 614 |
vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE; |
616 | 615 |
vpic->ReferenceFrames[i].TopFieldOrderCnt = ref->display_order; |
617 | 616 |
vpic->ReferenceFrames[i].BottomFieldOrderCnt = ref->display_order; |