]> git.sesse.net Git - ffmpeg/commitdiff
hevcdec: move the MD5 context out of HEVCSEIPictureHash back into HEVCContext
authorAnton Khirnov <anton@khirnov.net>
Fri, 12 May 2017 14:36:41 +0000 (16:36 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sat, 20 May 2017 07:41:30 +0000 (09:41 +0200)
HEVCSEIPictureHash should store only the information extracted from the
bitstream and exported to the higher layer (the decoder or the parser).
The MD5 context is allocated, used and freed by this higher layer, so it
makes more sense for it to also be stored there.

libavcodec/hevc_sei.h
libavcodec/hevcdec.c
libavcodec/hevcdec.h

index bdc283adb48fd179401cc379572c21c982c53c24..b699fef45dc229ea1485fdc5f26d53e7ed46e2a2 100644 (file)
@@ -23,8 +23,6 @@
 
 #include <stdint.h>
 
-#include "libavutil/md5.h"
-
 #include "get_bits.h"
 
 /**
@@ -59,7 +57,6 @@ typedef enum {
 } HEVC_SEI_Type;
 
 typedef struct HEVCSEIPictureHash {
-    struct AVMD5 *md5_ctx;
     uint8_t       md5[3][16];
     uint8_t is_md5;
 } HEVCSEIPictureHash;
index 96e47cd1875d0a3824069724150058ca8ae626ca..69d5908551949d5d4c39970ccb9fa77aa3dab606 100644 (file)
@@ -2683,7 +2683,7 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
         int h = (i == 1 || i == 2) ? (height >> desc->log2_chroma_h) : height;
         uint8_t md5[16];
 
-        av_md5_init(s->sei.picture_hash.md5_ctx);
+        av_md5_init(s->md5_ctx);
         for (j = 0; j < h; j++) {
             const uint8_t *src = frame->data[i] + j * frame->linesize[i];
 #if HAVE_BIGENDIAN
@@ -2693,9 +2693,9 @@ static int verify_md5(HEVCContext *s, AVFrame *frame)
                 src = s->checksum_buf;
             }
 #endif
-            av_md5_update(s->sei.picture_hash.md5_ctx, src, w << pixel_shift);
+            av_md5_update(s->md5_ctx, src, w << pixel_shift);
         }
-        av_md5_final(s->sei.picture_hash.md5_ctx, md5);
+        av_md5_final(s->md5_ctx, md5);
 
         if (!memcmp(md5, s->sei.picture_hash.md5[i], 16)) {
             av_log   (s->avctx, AV_LOG_DEBUG, "plane %d - correct ", i);
@@ -2893,7 +2893,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
 
     pic_arrays_free(s);
 
-    av_freep(&s->sei.picture_hash.md5_ctx);
+    av_freep(&s->md5_ctx);
 
     av_frame_free(&s->tmp_frame);
     av_frame_free(&s->output_frame);
@@ -2939,8 +2939,8 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
 
     s->max_ra = INT_MAX;
 
-    s->sei.picture_hash.md5_ctx = av_md5_alloc();
-    if (!s->sei.picture_hash.md5_ctx)
+    s->md5_ctx = av_md5_alloc();
+    if (!s->md5_ctx)
         goto fail;
 
     ff_bswapdsp_init(&s->bdsp);
index f2c589217f1f6c1f5093df5a44acaeb1a315b8a3..7adb826e722a8ecdd41db02e1635ee14c924cd3a 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdint.h>
 
 #include "libavutil/buffer.h"
+#include "libavutil/md5.h"
 
 #include "avcodec.h"
 #include "bswapdsp.h"
@@ -462,6 +463,7 @@ typedef struct HEVCContext {
 
     HEVCParamSets ps;
     HEVCSEI sei;
+    struct AVMD5 *md5_ctx;
 
     AVBufferPool *tab_mvf_pool;
     AVBufferPool *rpl_tab_pool;