Skip to content

Commit

Permalink
vda: fix h264 decoding for avcC,vda wants the entire buffer
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
FernetMenta committed May 22, 2015
1 parent e9400a9 commit a24ddea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libavcodec/h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
decode_postinit(h, nal_index >= nals_needed);

if (h->avctx->hwaccel &&
(ret = h->avctx->hwaccel->start_frame(h->avctx, NULL, 0)) < 0)
(ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0)
return ret;
if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
Expand Down
20 changes: 17 additions & 3 deletions libavcodec/vda_h264.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,20 @@ static int vda_h264_start_frame(AVCodecContext *avctx,
uint32_t size)
{
VDAContext *vda = avctx->internal->hwaccel_priv_data;

vda->bitstream_size = 0;

H264Context *h = avctx->priv_data;

if (h->is_avc == 1) {
void *tmp;
vda->bitstream_size = 0;
tmp = av_fast_realloc(vda->bitstream,
&vda->allocated_size,
size);
vda->bitstream = tmp;
memcpy(vda->bitstream, buffer, size);
vda->bitstream_size = size;
} else {
vda->bitstream_size = 0;
}
return 0;
}

Expand All @@ -333,6 +344,9 @@ static int vda_h264_decode_slice(AVCodecContext *avctx,
VDAContext *vda = avctx->internal->hwaccel_priv_data;
void *tmp;

if (h->is_avc == 1)
return 0;

tmp = av_fast_realloc(vda->bitstream,
&vda->allocated_size,
vda->bitstream_size + size + 4);
Expand Down

0 comments on commit a24ddea

Please sign in to comment.