[FFmpeg-devel] [PATCH] vda: fix h64 decoding, vda wants the entire buffer

Rainer Hochecker fernetmenta at online.de
Wed Apr 1 12:40:54 CEST 2015


---
 libavcodec/h264.c     |  2 +-
 libavcodec/vda_h264.c | 25 ++++++++-----------------
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index e8d5120..60f8aa1 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1589,7 +1589,7 @@ again:
                         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)
diff --git a/libavcodec/vda_h264.c b/libavcodec/vda_h264.c
index 081c366..d8053cf 100644
--- a/libavcodec/vda_h264.c
+++ b/libavcodec/vda_h264.c
@@ -320,8 +320,15 @@ static int vda_h264_start_frame(AVCodecContext *avctx,
                                 uint32_t size)
 {
     VDAContext *vda = avctx->internal->hwaccel_priv_data;
+    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;
 
     return 0;
 }
@@ -330,22 +337,6 @@ static int vda_h264_decode_slice(AVCodecContext *avctx,
                                  const uint8_t *buffer,
                                  uint32_t size)
 {
-    VDAContext *vda       = avctx->internal->hwaccel_priv_data;
-    void *tmp;
-
-    tmp = av_fast_realloc(vda->bitstream,
-                          &vda->allocated_size,
-                          vda->bitstream_size + size + 4);
-    if (!tmp)
-        return AVERROR(ENOMEM);
-
-    vda->bitstream = tmp;
-
-    AV_WB32(vda->bitstream + vda->bitstream_size, size);
-    memcpy(vda->bitstream + vda->bitstream_size + 4, buffer, size);
-
-    vda->bitstream_size += size + 4;
-
     return 0;
 }
 
-- 
2.1.0



More information about the ffmpeg-devel mailing list