Skip to content

Commit

Permalink
dxva-h264 Fix dxva playback of streams that don't start with an I-Frame.
Browse files Browse the repository at this point in the history
  • Loading branch information
marc authored and fritsch committed Sep 14, 2014
1 parent 24b62d4 commit 298c35c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libavcodec/dxva2_h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,14 @@ static int dxva2_h264_end_frame(AVCodecContext *avctx)

if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
return -1;

// Wait for an I-frame before start decoding. Workaround for ATI UVD and UVD+ GPUs
if (!h->got_first_iframe) {
if (!(ctx_pic->pp.wBitFields & (1 << 15)))
return -1;
h->got_first_iframe = 1;
}

ret = ff_dxva2_common_end_frame(avctx, &h->cur_pic_ptr->f,
&ctx_pic->pp, sizeof(ctx_pic->pp),
&ctx_pic->qm, sizeof(ctx_pic->qm),
Expand Down
1 change: 1 addition & 0 deletions libavcodec/h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ void ff_h264_flush_change(H264Context *h)
h->list_count = 0;
h->current_slice = 0;
h->mmco_reset = 1;
h->got_first_iframe = 0;
}

/* forget old pics after a seek */
Expand Down
2 changes: 2 additions & 0 deletions libavcodec/h264.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ typedef struct H264Context {
int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag
int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag

int got_first_iframe;

// Timestamp stuff
int sei_buffering_period_present; ///< Buffering period SEI flag
int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs
Expand Down
1 change: 1 addition & 0 deletions libavcodec/h264_slice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
ff_h264_free_tables(h, 0);
h->first_field = 0;
h->prev_interlaced_frame = 1;
h->got_first_iframe = 0;

init_scan_tables(h);
ret = ff_h264_alloc_tables(h);
Expand Down

0 comments on commit 298c35c

Please sign in to comment.