aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2016-06-26 15:44:35 +0200
committerHendrik Leppkes <h.leppkes@gmail.com>2016-06-26 15:44:35 +0200
commitd3327b7eda97523d1f4555f0f3615c69cd9ab65a (patch)
tree9efe19cfd8a76156d39f57b1f7d372d4af47fa7d /libavcodec
parent18b1b8be6a2a3f5c406f51417e8d19a517cf11a5 (diff)
parentb51c7c6b8a5b35cfd06cb9655f9ec4c9f0ddd81b (diff)
downloadffmpeg-d3327b7eda97523d1f4555f0f3615c69cd9ab65a.tar.gz
Merge commit 'b51c7c6b8a5b35cfd06cb9655f9ec4c9f0ddd81b'
* commit 'b51c7c6b8a5b35cfd06cb9655f9ec4c9f0ddd81b': vaapi_h264: Fix frame_num after non-reference frames Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/vaapi_encode_h264.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 4802929f93..b304a6650d 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -101,8 +101,8 @@ typedef struct VAAPIEncodeH264Context {
int fixed_qp_p;
int fixed_qp_b;
+ int next_frame_num;
int64_t idr_pic_count;
- int64_t last_idr_frame;
// Rate control configuration.
struct {
@@ -592,12 +592,17 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
if (pic->type == PICTURE_TYPE_IDR) {
av_assert0(pic->display_order == pic->encode_order);
- priv->last_idr_frame = pic->display_order;
+ vpic->frame_num = 0;
+ priv->next_frame_num = 1;
} else {
- av_assert0(pic->display_order > priv->last_idr_frame);
+ vpic->frame_num = priv->next_frame_num;
+ if (pic->type != PICTURE_TYPE_B) {
+ // nal_ref_idc != 0
+ ++priv->next_frame_num;
+ }
}
- vpic->frame_num = (pic->encode_order - priv->last_idr_frame) &
+ vpic->frame_num = vpic->frame_num &
((1 << (4 + vseq->seq_fields.bits.log2_max_frame_num_minus4)) - 1);
vpic->CurrPic.picture_id = pic->recon_surface;
@@ -608,10 +613,9 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
for (i = 0; i < pic->nb_refs; i++) {
VAAPIEncodePicture *ref = pic->refs[i];
- av_assert0(ref && ref->encode_order >= priv->last_idr_frame);
+ av_assert0(ref && ref->encode_order < pic->encode_order);
vpic->ReferenceFrames[i].picture_id = ref->recon_surface;
- vpic->ReferenceFrames[i].frame_idx =
- ref->encode_order - priv->last_idr_frame;
+ vpic->ReferenceFrames[i].frame_idx = ref->encode_order;
vpic->ReferenceFrames[i].flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE;
vpic->ReferenceFrames[i].TopFieldOrderCnt = ref->display_order;
vpic->ReferenceFrames[i].BottomFieldOrderCnt = ref->display_order;